Attempt to index global 'Addpoint'(a nil value)

I continue to get this error and I cannot figure out what is causing it. If you can help that would be great! Thanks!

StaleRP\gamemode\respect_system.lua:10: attempt to index global ‘ply’ (a nil value)



function Addpoint()
local mymessage = "You just got a respect point, you have " .. ply:GetNWInt("Points") .. " points!";
ply:SetNWInt("Points", ply:GetNWInt("Points") + 1)
ChatSay(mymessage)
end


Make it Addpoint(ply) and call it by using Addpoint(ply).

Thanks, however now I get this error:
StaleRP\gamemode\respect_system.lua:10: attempt to index local ‘ply’ (a nil value)
local mymessage is on line 10 shown in the code below.



function Addpoint(ply)
local mymessage = "You just got a respect point, you have " .. ply:GetNWInt("Points") .. " points!";
ply:SetNWInt("Points", ply:GetNWInt("Points") + 1)
ChatSay(mymessage)
end

Also it is called in Cl_init.



timer.Create("GivePoint", 1, 0, Addpoint(ply))


[lua] timer.Create(“GivePoint”, 1, 0, Addpoint,ply)[/lua]
:smile:

Define PLY!

The player object doesn’t just magically appear, it has to come from somewhere!

Shouldn’t you be doing the “local mymessage” line after adding the extra point, otherwise the message will be 1 point behind the player…

He shouldn’t be doing this in cl_init.lua either, but you know :sun:

Okay thanks but where should I put this part of the script? (Gbps)

init.lua or anything that starts with sv_ in your gamemode. That will make it call it on the server, not the client.

Thank you so much! I don’t get the errors however it doesn’t display a chat message but I can debug that tomorrow. Thank you again!