Help with Data tables and networkVar

I am running into issues using networked variables and the wiki isnt being much help. My goal is to have a boolean value that I can change.

This one runs without lua errors but when I do “GetCanDropAmmo” it always returns false no matter what number I put in there



function ENT:SetupDataTables()
	self:NetworkVar( "Bool", 1, "CanDropAmmo")
end


And this gives me a lua error



function ENT:SetupDataTables()
	self:NetworkVar( "Bool", true, "CanDropAmmo")
end


Where line 77 is
" local CanAmmo = self:GetCanDropAmmo() "

and 97 is the my custom function under ENT:Use.

second argument must be a number, it means the ID of the networkvar, not default value.

You’re meant to set up the NetworkVar so that you can set the value later, probably in ENT:Initialize(), using self:SetCanDropAmmo( true ), ENT:SetupDataTables() is only for creating the NetworkVars.

Thanks both of you




[function ENT:SetupDataTables()
	self:NetworkVar( "Bool", 1, "AmmoCanDrop")
	self:SetAmmoCanDrop( true )
end