local UIP = game:GetService("UserInputService") animation1 = Instance.new("Animation", script.Parent) script.Parent.Equipped:Connect(function() animation1.AnimationId = "rbxassetid://"..3358846513 local animationtrack1 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(animation1) animationtrack1:Play() end) script.Parent.Unequipped:Connect(function() animation1.AnimationId = "rbxassetid://"..3358846513 local animationtrack1 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(animation1) animationtrack1:Stop() end)
When the tool is unequipped, the script is supposed to stop the animation from playing, but it just keeps looping. Why?
You want to create and use LoadAnimation outside of these events so both event functions has the animation.
Also you don't want to use the second parameter of Instance.new() because of this.
local UIP = game:GetService("UserInputService") local animation1 = Instance.new("Animation") animation1.AnimationId = "rbxassetid://"..3358846513 animation1.Parent=script.Parent local animationtrack1 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(animation1) script.Parent.Equipped:Connect(function() animationtrack1:Play() end) script.Parent.Unequipped:Connect(function() animationtrack1:Stop() end)