I assume you’re using CharacterAdded. CharacterAdded is kind of strange as it fires before the character is actually parented to the game, and is actually parented to nil during this state. I assume the error stems from the fact that you immediately try to load the animation before the character can be parented to the workspace. There are a couple methods I’ve found to circumvent this, but this usually works for me:
local Player = Player -- Set the player here.
Player.CharacterAdded:Connect(Character)
Character.AncestryChanged:Wait() -- Wait for the character to change parents (usually means its parented to workspace/game).
local Humanoid = Character:WaitForChild("Humanoid") -- Get the Humanoid.
local Loaded = Humanoid:LoadAnimation(Animation) -- Load the animation.
end)
There have been other posts about this before, so make sure you also always search up about something before posting onto here, and you can read those posts below:
I hope this helps!