Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I cant resolve this error code about leaderstats, can you help?


script.Parent.ClickDetector.MouseClick:Connect(function() 
	script.NoobClick:Play() 
	game.Players.PlayerAdded.leaderstats.Money.Value = game.Players.PlayerAdded.leaderstats.Money.Value +1
end)

The error is leaderstats is not a valid member of RBXScriptSignal - Server - ClickScript:5

1 answer

✓ Accepted answer

The problem is that game.Players.PlayerAdded is an event signal not an object. Altougth to get the player use the argument that is given by the MouseClick event.

Example of this would be:

script.Parent.ClickDetector.MouseClick:Connect(function(player)
    -- Code here
end)

Also, you can increment values easier by using the += sign.

Example:

local a = 0
a += 1 -- Var a will now be 1 because this added 1 to the number
a += 4 -- Var a will now be 5 because this added 4 to the number

Full Script:

script.Parent.ClickDetector.MouseClick:Connect(function(player)
    script.NoobClick:Play()
    player.leaderstats.Money.Value += 1
end)

1 comment

0

bro thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.