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

How to make a click detector stat change save?

I have a one time stat adder and I want to make that one time stat change save over when you leave. So basically when you leave you still cant click the object again for another stat gain.

Here is my script so far: 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)

Thanks to anyone who helps!

3 comments

0

You can add a book value to a data store. When the player clicks the part, set the value to true. If the value is already true, then return end

0

Bool*

0

Thank you but can I get an example of the script?

1 answer

✓ Accepted answer

"I have a one time stat adder and I want to make that one time stat change save over when you leave. So basically when you leave you still cant click the object again for another stat gain.

Here is my script so far:
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)

Thanks to anyone who helps!"

Well I saw your earlier post and uh... someone told you but you didn't fully understand what he said. if you have a datastore you might just wanna add a Check in there called "Kirbie" and make it's class a Bool Value

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)

Would be a way I would do it. However, I'm not a professional on debounce so sorry if this is not the solution you are looking for.

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