Reputation: 11
So, I want to do the simple task of playing an animation on the player when you spawn in the game. I'm confused as to why it's not playing, because I ripped the script directly from Roblox documentation (except that I added my own animation).
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
-- Ensure that the character's humanoid contains an "Animator" object
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
-- Create a new "Animation" instance and assign an animation asset ID
local myAnimation = Instance.new("Animation")
myAnimation.AnimationId = "rbxassetid://88287635939752"
-- Load the animation onto the animator
local myAnimationTrack = animator:LoadAnimation(myAnimation)
-- Play the animation track
myAnimationTrack:Play()
This is a local script in StartPlayerScripts
I tested the animation itself, and it works perfectly fine on dummies with humanoids. I've printed the classes and names off all the variables and they all return what they're supposed to. Where could the problem be?
Upvotes: 0
Views: 383
Reputation: 698
There are multiple causes why animations may not seem playing:
task.wait(5)
on top of your script and playtest again. If you have a short animation, it could be that the animation played while the playtest was booting up.Upvotes: 1