This is in a local script that is placed in StarterPlayerScripts.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid:LoadAnimation(example anim)
this will work almost every time, but i’ve been getting reports about the script not working, the error message is “LoadAnimation requires the Humanoid object (player.Humanoid) to be a descendant of game object” , despite having clearly done WaitForChild().
might because sometimes for a frame or two the player model/character exists but hasn’t been parented to the workspace, so it would just exist in limbo for a bit. “to be a descendant of game object” just means it has to be parented to something else. I think you just have to add a wait command until the character is fully loaded with something like this
I often opt to skip finding the humanoid directly and I haven’t had any more issues
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local LoadedAnim = Character.Humanoid:LoadAnimation(ExampleAnim)
And to play the animation you can just use LoadedAnim:Play()