Changing idle animation ingame not working?

How do I change an idle animation ingame? The code from the developer guide doesn’t work Using Animations | Documentation - Roblox Creator Hub

local animateScript = char:WaitForChild("Animate")
animateScript.idle.Animation1.AnimationId = "rbxassetid://6146379526"
animateScript.idle.Animation2.AnimationId = "rbxassetid://6146379526"

local useranim = hum:LoadAnimation(script:WaitForChild("TH_USERIDLE"))
useranim:Play()

I also changed up the animate script a bit,

idle = 	{	
				{ id = script:WaitForChild("idle"):WaitForChild("Animation1").AnimationId, weight = 10}
			},

It works if I don’t move, but that’s since I’m playing it. The second I move and stop again it does a little thingy where it looks like it’s supposed to go back to that animation but then gets cancelled and plays the orignial animation.

1 Like

Humanoid:LoadAnimation() is now deprecated, use Animator:LoadAnimation(), a child of the humanoid instead to play animations.

2 Likes

Alright, thanks for the info but that doesn’t solve my initial problem.

1 Like

As @ItzMeZeus_IGotHacked said, Humanoid:LoadAnimation() is deprecated and must not be used for future works as the simplicity goes (pretty self-explanatory). And instead of using those things ROBLOX provided in their tutorial guide, it’s preferable to find any changes to the Humanoid. To find the changes in a Humanoid, we can use the given events for the Humanoid to find what happened to their states.

Animator:

Humanoid stuff:

And to give an idle animation to a player, we can just use an if statement IF the Humanoid is NOT running. I know it’s all bamboozling than the things you’re learning right now but this one will surely come in handy!

2 Likes

Yes you can also copy the things that were provided as sample codes to give an example of how they run in a game. You can definitely change them when you have the brains to pull it off :ok_hand:

Thank you, I managed to make it work by checking the humanoid MoveDirection and then setting the animation based on that.

1 Like