I am trying to make a tool that plays an animation once its equipped, but the animation won't play. I get no errors in console, and the print is displayed in console.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animation = Instance.new("Animation")
animation.Parent = script.Parent
animation.AnimationId = "rbxassetid://2156799740"
script.Parent.Equipped:Connect(function()
local AnimTrack = humanoid:LoadAnimation(animation)
AnimTrack.Priority = Enum.AnimationPriority.Action
AnimTrack:Play()
print("Animation done!")
end)

8 comments
Did you make the animation? You cannot use other people's animation
Is the animation in the same R6 or R15 as your character?
I made the animations myself, I am aware of not being able to use other peoples. The animation was made in an r15 model, and is being loaded on an r15 player.
did you set the priority of the animations to "action"?
Just tested in a new baseplate, and it works, but as soon as I publish it to Roblox as a game, it stops working.
is looping enabled on the animation? Looping the animation keeps the animation playing
I have tested it with looping on and off, tried different priority settings, and just about everything. As soon as I publish the game online is when the animations stop working
Just published the game to another place entirely, and it started working again, so something to do with the place that I published it too is causing them not to work, which is odd