#I can't use LoadAnimation

1 messages · Page 1 of 1 (latest)

worldly pebble
#

I tried Humanoid and just found out they changed Humanoid now you need to use Animator but it didn't work either
I did this,

#
local Animation = script:WaitForChild("WalkAnim1")

local hum = script.Parent:WaitForChild("Humanoid")

local AnimTrack = hum:WaitForChild("Animator"):LoadAnimation -- Didn't work so I didn't type the rest here 
------------------------------------
local char = script.parent
local hum = char:WaitForChild("Humanoid")
local Anim = hum:WaitForChild("Animator")
local AnimTrack = Anim:LoadAnimation
-------------------------------------
local Anim = script.parent:WaitForChild("Humanoid"):WaitForChild("Animator")
local AnimTrack = Anim:LoadAnimation
```  None of them worked here
chilly palm
worldly pebble
#

I know but it doesn't even let me use LoadAnimation from the start so I can give it a animation id

#

I was just lazy didn't want to type the rest there

chilly palm
worldly pebble
#

I just ignored the fact it doesn't even let me see this thing when I type "Load" but I tried typing
LoadAnimation(Animation) and it did nothing no work let me try again maybe I get a specific error

#

It says " Unable to cast value to Object "

#

Oh also if I put it somewhere wrong

#

the explorer looks like this

chilly palm
fast nest
#

Why not separate them to variables and put print function between them. Just for a debug, you know?

lucid mountainBOT
#

studio** You are now Level 12! **studio

worldly pebble
#

the problem is obvious

#

I don't have problem with others

#

But yeah

#

Let me try it

chilly palm
fast nest
#

I am bad at english actually, does the words understandable?

worldly pebble
chilly palm
# worldly pebble oh?

"Animation" is a string, the word 'Animation'.

Animation is a variable that contains the animation object.

It's saying it can't convert a value to an object because it can't make a string an animation object

fast nest
#

btw, do you reads roblox documentation everytime actually?

worldly pebble
#

I never understood that I mean why do I have to use string to find something in explorer

worldly pebble
#

with stuff that I don't have to use string but

#

I did this and still it didn't do anything LoadAnimation didn't work

chilly palm
fast nest
#

you may print the var

worldly pebble
#

got it thanks

worldly pebble
#

also it plays the animation too I tried adding warn to the last part too

#

It did said "Animation Played"

chilly palm
worldly pebble
worldly pebble
copper crag
fast nest
worldly pebble
#

If the lenght of the animation is 0 then wait?

fast nest
#

it check for load

copper crag
worldly pebble
#

Ah

copper crag
#

the length is 0 until it is loaded

#

is everything in your rig unanchored?

worldly pebble
#

Let me check

#

Yeah it is

#

It plays it instantly

#

So it loads

copper crag
worldly pebble
copper crag
#

wait, you're playing it on the player's char?

worldly pebble
#

But I'm saying it again I don't think it's normal to Roblox not try to fill it auto when I type Load

#

Yeah StarterCharacterScripts

worldly pebble
#

mb

robust python
#

findfirstchild doesn't refine type so intellisense doesn't know what type of object it is

#

so loadanimation won't show

worldly pebble
#

Ah

robust python
#

you can assert type for intellisense if you really want to

worldly pebble
#

Then the problem is not in the script ?

robust python
#

(humanoid:WaitForChild("Animator")::Animator):LoadAnimation(...

copper crag
#

make AnimPlay.Looped = true and disable the Animate script inside player's char ingame
should work

robust python
#

could also do something like humanoid:FindFirstChildOfClass("Animator") which will also refine the type

worldly pebble
#
local Animation = script:WaitForChild("WalkAnim1")
print("Animation Found")
local char = script.Parent
print("Character Found")
local hum = char:WaitForChild("Humanoid")
print(hum.Animator," Humanoid Found")
local Anim = hum:FindFirstChildOfClass("Animator")
print("Found Animator")
local AnimPlay = Anim:LoadAnimation(Animation)
print("Animation Loaded")
repeat
    task.wait()
until AnimPlay.Length ~= 0
AnimPlay.Looped = true
AnimPlay:Play()
print("Animation Played")

Yeah it did show up LoadAnimation thanks but it doesn't show the animation on character anyways

robust python
#

findfirstchild has different behavior to waitforchild

#

it prob error check output window

#

coz animator not exist yet

worldly pebble
worldly pebble
robust python
#

o you said not work

#

make sure ur animation id is right

fast nest
#

What about check its Length

copper crag
worldly pebble
#

Let me put the id again

robust python
#

also priority etc

copper crag
worldly pebble
#

I just made a new ID for same animation and put it there also I rechecked avatar settings and clicked R6 again so at the end of the day

#

it does work

#

Thanks a lot