I have a script that plays the tool idle animation when equipped, and stops it when unequipped.
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local animation = Instance.new("Animation")
animation.Name = "ChipsIdle"
animation.Parent = script.Parent
animation.AnimationId = "http://www.roblox.com/asset/?id=6716230447"
local animtrack = humanoid:LoadAnimation(animation)
script.Parent.Equipped:connect(function()
animtrack:Play()
end)
script.Parent.Unequipped:connect(function()
animtrack:Stop()
end)
How would I detect when the tool is destroyed and stop the animation?
I’ve heard that when a tool is destroyed it stops all the scripts inside it from working but I’m not too sure if that’s true. I’ll try this in a minute and let you know if it works!
you also can try checking if the animation is playing like:
local player = game.Players.LocalPlayer
local playing = false
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local animation = Instance.new("Animation")
animation.Name = "ChipsIdle"
animation.Parent = script.Parent
animation.AnimationId = "http://www.roblox.com/asset/?id=6716230447"
local animtrack = humanoid:LoadAnimation(animation)
script.Parent.Equipped:connect(function()
if playing == false then
playing = true
animtrack:Play()
end
end)
script.Parent.Unequipped:connect(function()
if playing == true then
playing = false
animtrack:Stop()
end
end)