So I’m pretty new to tools and I need help figuring out what went wrong in my code. Basically there is a pipe that plays a swinging animation when you click but for some reason you’re still able to swing the “pipe” when the tool isn’t equipped even despite my counter measures.
local InputService = game:GetService("UserInputService")
local Tool = script.Parent
local CoolDown = false
local Equipped = false
Tool.Equipped:Connect(function()
Equipped = true
if Equipped == true then
local Plr = game.Players.LocalPlayer
local Swing = Tool.SwingAnimation
local SwingAnim = Plr.Character.Humanoid:LoadAnimation(Swing)
InputService.InputBegan:Connect(function(Input, Received)
if Input.UserInputType == Enum.UserInputType.MouseButton1 and not CoolDown then
CoolDown = true
-- Other Code
CoolDown = false
end
end)
end
end)
Tool.Unequipped:Connect(function()
Equipped = false
end)
EDIT: Also in an attempt to find the issue using print statements I found that the function that plays the animation when you click in the first place isn’t running which I do not understand as if that were true it wouldn’t animate or even detect if you were clicking for that matter.