Animation not working?

hey developers, i’ve been recently experimenting with ‘Moon Animation Suite’, probably a known plugin, and i attempted to create that the animation loads on the clicker once clicked.
here is my code:

script.Parent.MouseButton1Click:Connect(function()
   local anim =  game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(5619884010)
   anim:Play()
end)

hierarchy:
image

the error in the output is:
Unable to cast value to Object

i understand it is kind of risky using localscripts for loading animations, but my remoteevents weren’t working so i just done this yk.

any help, tips or suggestions would be greatly appreciated,
thanks

You are passing an animation ID to the :LoadAnimation function while you should be passing the animation object itself. You can either insert an animation in the script or do:

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://id here"

local animTrack = humanoid:LoadAnimation(anim)
animTrack:Play()

More information about :LoadAnimation here.

2 Likes