• Noob Network Var Help
    3 replies, posted
Hey guys im fairly new to lua coding and im just trying to grasp everything. So I'm trying to make a SENT and I'm having trouble accessing my networkvars inside the init.lua file in functions without the "ENT" tag function ENT:SetupDataTables() self:NetworkVar("Bool", 0, "IsBeingRaided") self:NetworkVar("Int", 1, "RaidTime") end function beginRaid() if (self:GetIsBeingRaided()) then return end self:SetIsBeingRaided(true) timer.create("countdownTimer", 1, timeToRaid, function() self:SetRaidTime(self:GetRaidTime() -1) if(self:GetRaidTime() == 0) then endRaid() end end) endRaid() end Also very sorry about the snippet above, I spent 15 minutes trying to space everything out to how it is in my editor and the thing will not let me When I run this it hits me with "attempt to index global 'self'" which makes sense because the function isn't prefixed by ENT but if I want to access this network var within a user defined function how would I go about doing that?
I may be wrong but just have the function beginRaid have an argument self. Then when you call it inside an ENT function and provide self as the first argument, then everything should be working.
Make an argument to function which player is being raided and access him.
oh lol that makes so much sense thanks
Sorry, you need to Log In to post a reply to this thread.