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

Tool Currency Giver Cooldown?

Hello, I Really Need Help In This And I'm A Beginner Is Coding So Could You Please Help Me With This Script??

local db = false
local tool = script.Parent
repeat wait() until tool.Parent.Parent:IsA("Player")
local plr = tool.Parent.Parent
local character = plr.Character

tool.Activated:Connect(function()
    if not db then
        plr.leaderstats.Power.Value = plr.leaderstats.Power.Value + 1
        db = false
    end
end)

1 answer

Your debounce isn't set up correctly. You set debounce to false even though it is already false and you have no cooldown.


local db = false
local tool = script.Parent
repeat wait() until tool.Parent.Parent:IsA("Player")
local plr = tool.Parent.Parent
local character = plr.Character

tool.Activated:Connect(function()
    if not db then
        db = true
        plr.leaderstats.Power.Value = plr.leaderstats.Power.Value + 1
        wait(1) -- this is the cooldown, edit 1 to whatever number to make it longer or shorter
        db = false
    end
end)

You can use roblox's sample on debounce if you need more help with it: https://developer.roblox.com/en-us/articles/Debounce

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