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
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