How Do you play animation when player entered the game?

Im Not Really a scripter myself, so I do prefer the full script where should I paste it. The title explains itself. I Need a script for when the player joins the game an animation plays.

Put a LocalScript under StarterPlayer > StarterCharacterScripts with the following code:

game.Players.LocalPlayer.CharacterAdded:Connect(function()
	local anim = Instance.new("Animation")
	anim.AnimationId = "http://www.roblox.com/asset/?id=idhere" --put id where it says idhere
	local playAnim = humanoid:LoadAnimation(anim)
	playAnim:Play()
end)

Does the animation need to have a certain priority? (Animation Priotity?)

Set it above any of the default priorities that are used in the player’s walking and such. I’d just pick 4 (action) to override everything. Also, note that if you have looping toggled on in the anim, then it will never stop unless you manually stop it.

Alright, Ill try that out right now.

Weird. It doesn’t work for me.


game.Players.LocalPlayer.CharacterAdded:Connect(function()
	local anim = Instance.new("Animation")
	anim.AnimationId = "http://www.roblox.com/asset/?id=idhere" --put id where it says idhere
	local playAnim = humanoid:WaitForChild("Animator"):LoadAnimation(anim)
	playAnim:Play()
end)

they were using the deprecated method
use the humanoids’ animator instead

Nope, this doesn’t work too. Maybe it’s a good warning that Im actually using smooth first person script too. Im not sure if it messes up the script

Temporarily disable it and see if the script now works.

Wait, I think i have it! I think it wasn’t working cause humanoid was undefined, whoops!

game.Players.LocalPlayer.CharacterAdded:Connect(function()
	local anim = Instance.new("Animation")
	anim.AnimationId = "http://www.roblox.com/asset/?id=idhere" --put id where it says idhere
	local playAnim = game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(anim)
	playAnim:Play()
end)

Please check if this works.

I Think it’s because the script loads before the character is added to the game.

That is not the cause, because Player.CharacterAdded waits until the character is loaded before continuing.

Still Doesnt work. Im gonna try removing a first person script

Its a server script where you change players animation.

This script isn’t the cleanest way to do this, but it should work.

local player = game.Players.LocalPlayer
repeat wait() until player.Character:FindFirstChild("Humanoid")
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=idhere" --put id where it says idhere
local playAnim = game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(anim)
playAnim:Play()
2 Likes

take @LoordySr’s advice
add a server script in ServerScriptStorage

local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
 player.CharacterAdded:Wait()
	local anim = Instance.new("Animation")
	anim.AnimationId = "http://www.roblox.com/asset/?id=idhere" --put id where it says idhere
	local playAnim = player.Character:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(anim)
	playAnim:Play()

end)

A function where the animation plays onPlayerJoin would work ?

i bet it will attempt to index nil with "Humanoid"
well nice try

It works, I tested it in my own game.

It Worked. Thanks for your help!