• NetworkVar working for one, but not other
    2 replies, posted
In my info.lua (clientside) I have function ENT:SetupDataTables() self:NetworkVar("String", 0, "Recipe"); end and I am setting it with local bread_button = vgui.Create( "DButton", recipeMenu ) bread_button:SetText("Bread") bread_button:SetPos( 25, 50 ) bread_button:SetSize(250, 30) bread_button.DoClick = function() ent:SetRecipe("Bread") end and that works fine, it send it to my cl_init.lua and I can use it, but when I try and do a second var defined in my init.lua I get problems init.lua function ENT:SetupDataTables() self:NetworkVar("String", 1, "ItemOne") end function ENT:Touch(ent)     if(ent:GetClass() == "flour") then         self:SetItemOne("Flour")     end end cl_init.lua function ENT:Draw() self:DrawModel() local recipe = self:GetRecipe() local itemOne = self:GetItemOne() print(recipe) print(itemOne) end recipe returns Bread, but itemOne returns "attempt to call method 'GetItemOne' (a nil value)" Thank you, Endus
You need to define the Data Tables only in 1 file, and that is the shared file. Both the client and the server need to have the same network vars.
This and you have to call `SetRecipe` server side if you want the value to not be overwritten, and be visible from the server.
Sorry, you need to Log In to post a reply to this thread.