I've been making a game and I need a click detector to add to someones stat on click. I want to make it so when you click it you won't ever be able to click it again even if you leave and rejoin. I currently have this script and will you tell me whats wrong and the fixed script? Thanks!

local Debounce = {}

script.Parent.ClickDetector.MouseClick:Connect(function(player)

if Debounce[player] then return end

Debounce[player] = true

local stat = player:WaitForChild(“leaderstats”)[“Kirbies Found”]

stat.Value = stat.Value + 1

end)

script.Parent.ClickDetector.MouseClick:Connect(function(player)

if player:FindFirstChild(“Kirbie”).Value == true then

return

end

player:FindFirstChild(“Kirbie”).Value = true

local stat = player:WaitForChild(“leaderstats”)[“Kirbies Found”]

stat.Value = stat.Value + 1

end)

end)

4 comments

0

player:WaitForChild(“leaderstats”).[“Kirbies Found”]

0

Thanks but it still doesn't add the stat.

0

Is “Kirbie” just a value of true or false that is in the player but not leaderstats?

0

I was asking how to make the click one time even if you leave and the person said to use that I think its a bool value or something?