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

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

Asked by 4 years ago

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)

Closed as Not Constructive by User#6546

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)
0
It Doesn't Work... Derrick_Dage -128 — 4y
0
Try again, it should work. I fixed it SilentsReplacement 468 — 4y
0
It Still Doesn't Work Derrick_Dage -128 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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)
0
Please check the script again, and tell me what EXACTLY do you want SilentsReplacement 468 — 4y
0
It Doesn't Give Me The Stats Derrick_Dage -128 — 4y