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

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 tool = script.Parent
local player = script.Parent.Parent.Parent
	 
	tool.Activated:Connect(function()
	    player.leaderstats.Technology.Value = player.leaderstats.Technology.Value + 1
end)

2 answers

There is something called debounce.

local tool = script.Parent
local player = script.Parent.Parent.Parent
local debounce = false
    tool.Activated:Connect(function()
       if debounce then
        debounce = true
        player.leaderstats.Technology.Value = player.leaderstats.Technology.Value + 1
        end
        wait(2.5)
        debounce = false
end)

3 comments

0

It Doesn't Work...

0

Try again, it should work. I fixed it

0

It Still Doesn't Work

My Leaderstats is

function createLeaderstats(plr)
	local leaderstats = Instance.new("StringValue")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = plr
	
	local technology = Instance.new("IntValue")
	technology.Parent = leaderstats
	technology.Name = "Technology"
	technology.Value = 0
	
	local coins = Instance.new("IntValue")
	coins.Parent = leaderstats
	coins.Name = "Coins"
	coins.Value = 0
	
	local gems = Instance.new("IntValue")
	gems.Parent = leaderstats
	gems.Name = "Gems"
	gems.Value = 0
end

game.Players.PlayerAdded:Connect(function(plr)
	createLeaderstats(plr)
end)

2 comments

0

Please check the script again, and tell me what EXACTLY do you want

0

It Doesn't Give Me The Stats

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