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

How to make a click detector stat change save?

Asked by
IsPoyo -1
5 years 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 505 — 5y
0
Bool* Despayr 505 — 5y
0
Thank you but can I get an example of the script? IsPoyo -1 — 5y

1 answer

Log in to vote
0
Answered by 5 years 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