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

Changing Leaderstats with a Clickdetector?

script.Parent.MouseClick:Connect(function()
	if debounce == true then
		print ("Cooldown.")
	else
		debounce = true
		game.Players.PLAYERHERE.leaderstats.Clicks.Value = game.Players.PLAYERHERE.leaderstats.Clicks.Value + 1
		wait (0.05)
		debounce = false
	end 
end)

This is inside a script, which is inside a click detector, inside a button.

I'm trying to figure out what to put as "PLAYERHERE". "Local Player" does not work for me. I have tested that the script works with my own username, but of course, I want it to be for the person who clicked it.

1 answer

✓ Accepted answer
script.Parent.MouseClick:Connect(function(player)
    if debounce == true then
        print ("Cooldown.")
    else
        debounce = true
        player.leaderstats.Clicks.Value = player.leaderstats.Clicks.Value + 1
        wait (0.05)
        debounce = false
    end 
end)

Try this. The parameter is the player that clicks the button so player is already defined.

1 comment

0

Thank you!

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