Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago

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

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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)
0
bro thanks RainbowmanO_o 2 — 2y
Ad

Answer this question