Hi there I am having a bit of trouble adding points to a player and wondering if anyone could give me some insight on what to do next, I have tried a couple of ways but I always hit a dead end, with an error saying “attempt to index global ‘pl’ (a nil value)” or something to that extent
So far in my init.lua I have
[lua]function GM:PlayerAuthed( pl, SteamID, UniqueID )
pl.total_points = pl:GetPData( “TotalPoints”, 0 )
pl:SetNWInt( “points”, pl.total_points )
pl.switched_this_round = false
pl.total_points = pl.total_points or 0
And then my scoreboard reads the points easily like so it it’s own scoreboard file…
if self.pl:GetNWInt("dead") == 1 then self.dead_label:SetText("Dead") else self.dead_label:SetText("") end for k, ply in pairs( player.GetAll() ) do local t_points = ply:GetNWInt( "points") self.total_points_label:SetText(t_points) end self:InvalidateLayout()
Now I have another file which is used to read input from a textbox where the user can input data and receive points, depending on what they have input, and I am having trouble giving the points to the player.
local Text = self:GetEntryValue();
local points = ply:GetPData(“TotalPoints”)
local function_name, count = Text:match( "([%w_]+)%((%d+)%);" ); ply:SetPData("TotalPoints", points + count) if function_name == "add_points" then end
I would expect that to work but all I get is the error: “attempt to index global ‘ply’ (a nil value)”
Would anybody be kind enough to shed some light on my problem, possible tell me where I am going wrong, and what file to put this adding points thing in?
Thank you in advance!