So I have had an issue with values not saving to a leaderboard because it was a local script so here I have a server script I made but I get the following error:
Script:3: attempt to index local 'user' (a nil value)
So the problem is, how do I get the player who clicked the text button in a server script?
local function onClicked(player)
local user = game.Players:GetPlayerFromCharacter(player)
local stats = user:findFirstChild("leaderstats")
if stats ~= nil then
local cash = stats:findFirstChild("Money")
cash.Value = cash.Value + 500
else
print("Error1")
end
end
script.Parent.MouseButton1Click:connect(onClicked)

3 comments
the player argument in the function is the player so the line 2 is usless
How should it know that you want the player who clicked it to be the local player?
That is one of my problems that I do not know how to deal with.