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

Why does the script break on this line, and can I make it work while having ("Cooldown = false")?

Asked by
das1657 20
3 years ago

So I have a localscript inside a tool and basically whenever you click with the tool equipped its supposed to fire a remote event and run an animation while having a value = false. The tool works fine without the if Tool.Handle.Cooldown == false then but I want it to make the code run if Cooldown = false and not make it run if Cooldown = true. Im a bit of a noob at scripting so if its obvious I probably wont know


local plr = game.Players.LocalPlayer local ReplicatedStorage = game:GetService("ReplicatedStorage") local Attack = ReplicatedStorage:WaitForChild("OnAttackSword") local char = plr.Character local Tool = script.Parent Tool.Activated:Connect(function() if Tool.Handle.Cooldown == false then -- this line breaks the entire script print("Stone Sword was Activated") game.ReplicatedStorage:FindFirstChild("OnAttackSword"):FireServer(char) local animation = plr.Character.Humanoid:LoadAnimation(script.Parent.Attack1) animation:Play() end end)

And yes, I checked if the value was false before running it

0
What is Tool.Handle.Cooldown? Is it a Value? If so, try Tool.Handle.Cooldown.Value ChristianTRPOC 64 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

try

local plr = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Attack = ReplicatedStorage:WaitForChild("OnAttackSword")
local char = plr.Character
local Tool = script.Parent

Tool.Activated:Connect(function()

    if Tool.Handle.Cooldown.Value == false then -- this line breaks the entire script
    Tool.Handle.Cooldown.Value = true
        print("Stone Sword was Activated")
        game.ReplicatedStorage:FindFirstChild("OnAttackSword"):FireServer(char)
        local animation = plr.Character.Humanoid:LoadAnimation(script.Parent.Attack1)
        animation:Play()
    wait(5) -- change 5 to how much time you want the cooldown to be 'o'
    Tool.Handle.Cooldown.Value = false
    end

end)

if it still doesn't work, dm me on discord

Blue Duck#8344

0
It was late and I forgot the (.Value), but thanks for making a cooldown because this new cooldown is better than an old one I made das1657 20 — 3y
Ad

Answer this question