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

Tool Currency Giver Cooldown? [closed]

Asked by 4 years ago

This question already has an answer here:

How Do I add an cooldown in this tool??? (help please)

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)

Marked as Duplicate by User#6546

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
OhManXDXD 445 Moderation Voter
4 years ago

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

Ad