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

Leaderstats GUI Button Script For StarterGUI Not Working?

Asked by 6 years ago

So, i'm making a simulator where you click a gui button, and it raises your leaderstat. (The leaderstat is called Snow) I have a script, but it won't work. Anyone know why? Thank you.

debounce = false

function onClick(Player)
    if not debounce then
        debounce = true
            for _,Player in pairs(game.Players:GetPlayers()) do
            if Player:findFirstChild("leaderstats") then
            Player.leaderstats.Snow.Value = Player.leaderstats.Snow.Value +1
            wait(0.1)
            debounce = false

            end
        end
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClick)

1 answer

Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
6 years ago

It may have something to do with the debounce. It is in the if statement, so it might not change to false

debounce = false

function onClick(Player)
    if not debounce then
        debounce = true
        for _,Player in pairs(game.Players:GetPlayers()) do
            if Player:FindFirstChild("leaderstats") then
                Player.leaderstats.Snow.Value = Player.leaderstats.Snow.Value +1
                wait(0.1)
            end
        end
        debounce = false
    end
end

script.Parent.ClickDetector.MouseClick:Connect(onClick)
Ad

Answer this question