#I can't use LoadAnimation
1 messages · Page 1 of 1 (latest)
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
You need to actually give an animation to LoadAnimation, it doesn't magically load the desired animation
The Animator is what manages the animations, so you need to give it something to load.
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
Doesn't let you use how so? Is it giving you an error?
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
Show me the code that actually tries to load the animation
Why not separate them to variables and put print function between them. Just for a debug, you know?
** You are now Level 12! **
I mean
the problem is obvious
I don't have problem with others
But yeah
Let me try it
You need to pass Animation into LoadAnimation, not "Animation"
I am bad at english actually, does the words understandable?
Yeah I was just doing what you said
oh?
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
btw, do you reads roblox documentation everytime actually?
I never understood that I mean why do I have to use string to find something in explorer
Few time
That makes me mix stuff
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
WaitForChild is just a function that waits for the child with the given name, which is why you give it a string
you may print the var
Oh so it gets the object or script or anything using their names
got it thanks
Let me try
also it plays the animation too I tried adding warn to the last part too
It did said "Animation Played"
So if the animation says it played, but it didn't, what priority is your animation set as? Does the animation object have an ID?
Yeah it does
"rbxassetid://88938103222459"
I didn't find any errors there
try using
repeat
task.wait()
until AnimPlay.Length ~= 0
I just meant to check if it exist. But it should exist anyway, sorry.
Yeah it does lol
Alright
It did nothing but what did it meant to do anyways?
If the lenght of the animation is 0 then wait?
it check for load
wait until the animation is loaded
Ah
yes
is the animation made for the same type your rig is (r6, r15)?
Animation is r6 and the rig is r6 avatar is r6 too
wait, you're playing it on the player's char?
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
it is normal
mb
findfirstchild doesn't refine type so intellisense doesn't know what type of object it is
so loadanimation won't show
Ah
you can assert type for intellisense if you really want to
Then the problem is not in the script ?
(humanoid:WaitForChild("Animator")::Animator):LoadAnimation(...
make AnimPlay.Looped = true and disable the Animate script inside player's char ingame
should work
could also do something like humanoid:FindFirstChildOfClass("Animator") which will also refine the type
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
@worldly pebble
findfirstchild has different behavior to waitforchild
it prob error check output window
coz animator not exist yet
Wait I will do it
What about check its Length
he already is
Let me put the id again
also priority etc
it's not 0 because it's loading