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

How do I make it so you can only use the tool for 10 seconds then there's a 1 minute cooldown?

Asked by 4 years ago

I want to make it so you can only use the tool for 10 seconds, then you have to wait 1 minute to use it again.

local cd = true
local tool = script.Parent
local player = game.Players.LocalPlayer

tool.Equipped:Connect(function()
    game.ReplicatedStorage.Phase:FireServer(true)
end)

tool.Unequipped:Connect(function()
    game.ReplicatedStorage.Phase:FireServer(false)
end)

1 answer

Log in to vote
0
Answered by 4 years ago

There’s many ways to do this.

You could on the server make the player added to a table that stops them from requesting again when found in it to initiate the cooldown.

For the 10 seconds timer, just use coroutine that automatically adds the player to the table on the server side or requests the event to do this as a spawned function. Example of coroutine use:

coroutine.wrap(function()
    game.ReplicatedStorage.Phase:FireServer(true)
end)()

Due to how broad the question is, it is up to you on how you want to implement it.

Ad

Answer this question