This is local script in the tool and it is not working properly, it plays animation after tool is unequipped. I think I need to add "check if tool is equipped" but I don't know how to do it.
local Tool = script.Parent
local Player = game.Players.LocalPlayer
local Character = Player.Character or script.Parent
local Humanoid = Character.Humanoid
local UserInputService = game:GetService("UserInputService")
local AnimationID = 'rbxassetid://4868889544'
local Animation = Instance.new("Animation")
Animation.AnimationId = AnimationID
local LoadAnimation = Humanoid:LoadAnimation(Animation)
local key = 'R'
local debounce = true
-- how to check if tool is equipped?
Tool.Equipped:Connect(function()
UserInputService.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
if Input.KeyCode == Enum.KeyCode[key] and debounce == true then
debounce = false
LoadAnimation:Play()
wait(3)
debounce = true
end
end)
end)
-- how to check if tool is unequipped?
Tool.Unequipped:Connect(function()
LoadAnimation:Stop()
LoadAnimation:Destroy()
end)

2 comments
Thank you so much!!! I have been trying to finish my script for 2 weeks but I am bad at scripting, and today I finally did it :D
:)