I want to make it where when i equip a tool a animation plays, and when i unequip it, the animation should stop. When i unequip it, the animation still plays.
help
local Tool = script.Parent local Animation = Tool.Animation Tool.Equipped:Connect(function() local Player = Tool.Parent local Humanoid = Player.Humanoid local Animator = Instance.new("Animator") local AnimationPlay = Humanoid.Animator:LoadAnimation(Animation) AnimationPlay:Play() end) Tool.Unequipped:Connect(function() local Player = Tool.Parent local Humanoid = Player.Humanoid local Animator = Instance.new("Animator") local AnimationPlay = Humanoid.Animator:LoadAnimation(Animation) AnimationPlay:Stop() end)
instead of:
local AnimationPlay = Humanoid.Animator:LoadAnimation(Animation) AnimationPlay:Stop()
try:
for i,child in pairs(Humanoid:GetPlayingAnimationTracks()) do if child.Animation.AnimationId == “rbxasset//insert_animation_id” then child:Stop() end end
hopefully it works out :D