So I found a tool idle animation script. I tried it out, and it works, but when I equip the box with the idle animation, then I equip another tool, it does the idle animation that I don’t want it to do. How do I fix this?
local Tool = script.Parent
local IdleAnimation = "rbxassetid://5608461772"
local Anim = Instance.new("Animation", Tool)
Anim.Name = "Animation"
Anim.AnimationId = IdleAnimation
Tool.Equipped:Connect(function()
local Character = Tool.Parent
local Player = game.Players:GetPlayerFromCharacter(Character)
if Player ~= nil then
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid ~= nil then
local LoadedAnim = Humanoid:LoadAnimation(Anim)
LoadedAnim:Play()
end
end
end)
Tool.Unequipped:Connect(function()
local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
if Character ~= nil then
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid ~= nil then
local Anims = Humanoid:GetPlayingAnimationTracks()
for i,v in pairs(Anims) do
if v.Animation.AnimationId == IdleAnimation then
v:Stop()
end
end
end
end
end)