Problem with loading and playing an animation on player

I’m having problems with loading and playing an animation on a player

Script Type: LocalScript

Errors: “Unable to cast value to Object”

Code:

	local Player = game.Players.LocalPlayer
	game.Players[Player.Name].Character.Humanoid:LoadAnimation("rbxassetid://5787348248"):Play()
1 Like
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset/?id=5787348248"

repeat wait() until game:GetService("Players").LocalPlayer.Character.Humanoid

game:GetService("Players").LocalPlayer.Character.Humanoid:LoadAnimation(animation):Play()

Maybe this will work

Please do a bit of research when you run into problems like this. You should try searching up what the error means, how to use the functions you’re calling or examples of the thing you’re trying to accomplish. If you go to the LoadAnimation API reference page, it shows that you need to call this with an Animation object rather than a string.

1 Like

Try to use a remote event to signal the server that a player is gonna do an animation, or else the server can’t see the player doing it.

No need for a remote. Clients are able to replicate animation playback through the Animator object.

I’m sorry but, can I have a script example?

When you use LoadAnimation, the Animator object is automatically created by the server and the player is given ownership of it. Because this Animator object exists, you don’t need remotes for animations. When a client plays an animation, the playback is replicated automatically.

So the server will see the player doing an action without telling the server?