Animation not playing when player's character loads

I want to make a simple animation play when the player’s character loads but for some reason it doesn’t play and roblox doesn’t give any error or warning for why it doesn’t play.

This is the script (normal script)

local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)

plr.CharacterAdded:Wait()

script.Parent.WalkSpeed = 0
local anim = script.Parent.Animator:LoadAnimation(script.Parent.Animation)
anim:Play()
anim.Ended:Wait()
script.Parent.WalkSpeed = 19

this is where it’s placed (the script’s name is play):
image

4 Likes

Try putting it in a local script in starter character scripts.

4 Likes

the walkspeed is set to 0 now but the animation still doesn’t play

2 Likes

It probably can’t find the animation try this

script.Parent.WalkSpeed = 0
local anim = script.Parent.Animator:LoadAnimation(script.Parent.Animation)
if anim then
print("Animation Loaded")
anim:Play()
end
anim.Ended:Wait()
script.Parent.WalkSpeed = 19
3 Likes

It returns “Animation Loaded” but the animation still doesn’t play

2 Likes

Maybe try returning the script to starterCharacter, but parent it to the model itself, not the humanoid.

2 Likes

same result

For some stress relief let’s enjoy this image:

2 Likes

Is the animation your own? If the animation doesn’t belong to the owner of the game or any group that owns the game then it won’t play.

Also could you test putting a task.wait(10) at the start or similar just to test if that works?

4 Likes

There must be some problem with the animation, It should be your own.

1 Like

my friend made the animation so it could be that :()

3 Likes

I tested with another animation (which I made this time) and it still didn’t work

try going to the animation editor, opening up the animation, and exporting it as your own.

1 Like

You could ask your friend to load the animation onto a rig, and then publish the animation under your own name to work around the issue. I’m not entirely sure if there’s a more direct way for your friend to grant you permissions.

3 Likes

I did that, same result as always

like I said in a previous comment, same result even if I was the one to upload the animation

That’s really weird, maybe something to do with the animation priority? Or maybe try removing the animation ended part and see if it plays.

2 Likes

Tried both and none worked and my brain is died

Hold up, I think I’m cooking something

I made the script a normal one and I added a task wait function and now it works!

3 Likes