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

My script doesn't return from cooldown?

Alright, so what this script is supposed to do is you activate it and it stays for 10 seconds, then after 10 seconds it deactivates and has a wait time of 45 to use it again whilst naming itself cooldown. But this isn't working, and I feel like it's probably something simple.

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

if tool.Activated:Connect() then
	    if cooldown == true then
			script.Parent.Name = "Phase"
	    	game.ReplicatedStorage.Phase:FireServer(true)
			wait(10)
			cooldown = false
	end
end

if cooldown == false then
	game.ReplicatedStorage.Phase:FireServer(false)
	script.Parent.Name = "CoolDown"
	wait(45)
	cooldown = true
end

1 answer

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

script.Parent.Activated:Connect(function()
        if cooldown == true then
            script.Parent.Name = "Phase"
            game.ReplicatedStorage.Phase:FireServer(true)
            wait(10)
            cooldown = false
            if cooldown == false then
              game.ReplicatedStorage.Phase:FireServer(false)
              script.Parent.Name = "CoolDown"
              wait(45)
              cooldown = true
           end
    end
end)

Try this^

2 comments

0

it works for the first time then it stays in cooldown

0

nevermind, fixed it, it would work just not change the name because it would only change the name WHEN you activated it not even when you dont activate. thanks

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