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

My script doesn't return from cooldown?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by
6zk8 95
4 years ago
Edited 4 years ago
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^

0
it works for the first time then it stays in cooldown MateeTheGod 0 — 4y
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 MateeTheGod 0 — 4y
Ad

Answer this question