Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How to make a click detector stat change save?

Asked by
IsPoyo -1
11 days ago

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!

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 Despayr 148 — 11d
0
Bool* Despayr 148 — 11d
0
Thank you but can I get an example of the script? IsPoyo -1 — 11d

1 answer

Log in to vote
0
Answered by 11 days ago

"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.

Ad

Answer this question