My script is not working how I expected it to

Can anyone help the script I made on the line below it was only supposed to give me + 50 coins every time. But it gave me more every time. Why?
player.leaderstats:FindFirstChild("Coins").Value += 50

Thanks for helping.

Did you just create an empty script and put that in there? If you did, then you should change it to this:
game.Players.PlayerAdded:Connect(function(player)
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50
end)

no it is in a remote event function.

Are you firing the event when the player press a key?

No mouse button click on a button.

I know the problem now! I used to have this problem too. But anyways, here’s how to solve it:

local debounce = false
button.MouseButton1Click:Connect(function() -- change the button to the one you use
    if not debounce then
        debounce = true
        remoteEvent:FireServer() -- change the remoteEvent here to your remote event
        wait(0.1)
        debounce = false
    end
end)

Let me try that, Just a moment.

Ok. If you find this working I would appreciate it if you mark this as solution so that other people can see it too.

1 Like

Thanks this works perfectly. Thanks Again!

1 Like