Please help! I can't take this anymore! How do I do animations!

I have had this problem for so long. I have made multiple posts about it, and whenever I think I finally figured it out, 10 more problems emerge. I just can’t get the animations working no matter what I do because Roblox doesn’t handle it right.

All I want to do is one very very simple thing: All I want to do is be able to change the idle and walking animations of players whenever I want to.

That’s it.

This is what I settled with at the beginning:

hit.Parent.Animate.walk.WalkAnim.AnimationId = "rbxassetid://8137104876"
hit.Parent.Animate.idle.Animation1.AnimationId = "rbxassetid://8137256167"
hit.Parent.Animate.idle.Animation2.AnimationId = "rbxassetid://8137256167"

That should work, but it doesn’t work properly because Roblox animation’s don’t play right. If you changed the walking animation while walking, then you would have to stop walking and start walking again in order for it to play, and vice versa.

Because of that, I looked up some help and finally got this:

hit.Parent.Animate.walk.WalkAnim.AnimationId = "rbxassetid://8137104876"
hit.Parent.Animate.idle.Animation1.AnimationId = "rbxassetid://8137256167"
hit.Parent.Animate.idle.Animation2.AnimationId = "rbxassetid://8137256167"

local AnimationTrack = hit.Parent:FindFirstChild("Humanoid"):LoadAnimation(hit.Parent.Animate.idle.Animation1)
AnimationTrack:Play()
local AnimationTrack = hit.Parent:FindFirstChild("Humanoid"):LoadAnimation(hit.Parent.Animate.walk.WalkAnim)
AnimationTrack:Play()

But this didn’t work either, because then the walking animation would always play, regardless if you are walking or not.

Then I changed it to this:

hit.Parent.Animate.walk.WalkAnim.AnimationId = "rbxassetid://8137104876"
hit.Parent.Animate.idle.Animation1.AnimationId = "rbxassetid://8137256167"
hit.Parent.Animate.idle.Animation2.AnimationId = "rbxassetid://8137256167"

if hit.Parent:FindFirstChild("Humanoid").MoveDirection == Vector3.new(0,0,0) then
	local AnimationTrack = hit.Parent:FindFirstChild("Humanoid"):LoadAnimation(hit.Parent.Animate.idle.Animation1)
	AnimationTrack:Play()
	local AnimationTrack = script.Parent:FindFirstChild("Humanoid"):LoadAnimation(hit.Parent.Animate.idle.Animation2)
	AnimationTrack:Play()
else
	local AnimationTrack = hit.Parent:FindFirstChild("Humanoid"):LoadAnimation(hit.Parent.Animate.walk.WalkAnim)
	AnimationTrack:Play()
end

But that still didn’t work sometimes for WHATEVER reason.

The main suspect for the animations never working is lag. Nothing but lag.

One very annoying thing is that I have almost 100 scripts in my game to change the animation, and every time I want to make 1 small change, I have to spend an HOUR copying and pasting it into every script then double checking over everything.

I change the animations from the server, not the client. I can’t change it now, because if I did then it would require an entire re-script of everything in the game, which would take days or maybe a week of constant work.

Please can somebody give me an animation script or method that is guaranteed to work at least 99% of the time. Nobody can understand how annoying and stressful this is, because every time I think I fixed it, it never is. My scripts have became super messy and unreadable, all because I can’t get this one simple goal working.

Just to clear things up: All of my animations are looped and set animation priority to core.

tl;dr: How do I change the idle and walking animations of a player from the server when I want to. (I suggest you read the whole thing so the story and context becomes more clear)

2 Likes

Yw in advance! :santa:

I already read all of that before and it didn’t give me a drop of knowledge. I just need somebody to send me a script and describe to me how it works, or they can tell me what I’m doing wrong so I can fix it. I don’t want to be trying out a bunch of different things again, I need just one things that works and one thing only.

1 Like
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:FindFirstChild("Humanoid")
local Animator = Humanoid:FindFirstChildOfClass("Animator")
local Animation = "" -- Animation there.

local animationTrack = Animator:LoadAnimation(Animation)
animationTrack:Play()
1 Like

I want to change the idle and walking animations individually. That’s all.

Ah, then I wouldn’t know how to do that. Apologies!

1 Like

Maybe try fiddling around with this

So the code does work but not consistently?

Yes. It works mostly in roblox studio, but in the game (and especially with other players in the game) sometimes I might experience a number of weird things such as:

-When I move or stop it plays the previous idle animation for a split second
-The idle animation plays when you walk
-Animation takes a while to actually play
-Sometimes it just straight up doesn’t do anything

Ok make the player jump evrey time you set an animation make jump power to 0 and problem solved that’s what I did when ihad the same problem as you

1 Like

That doesn’t sound like good practice, and it sounds like it could get very buggy

I’m not too well versed with animations but shouldn’t you be using priority: action? for customs?

the reason I say this is because roblox anims will override any low priority or at least I would assume so.

I did use action at first, but that doesn’t work too well when you use :LoadAnimation

Reason: Because animation would keep playing and never stop

I may be wrong here, but wouldn’t that be because you’re supposed to script it to where it will stop and play depending on conditions

When I tried out custom animations I had conditions set up to make lets say a crouch animation moving anim stop if not moving and play idle crouch, vice versa–i will check my code see if it can help"

edit: ok i don’t really want to release the code because its not that good but it does work–if a solution is not found i will post later

Every player has an animate script. Try to change animation’s id in these scripts.

The built-in animator handles that. That’s why you have to set the animation priority to core

You can’t change the contents inside a script, and also that’s what I’m doing, but I’m just loading in the animation afterwards because that seems to make it work better

You can change it.(Sorry for ui elements and other things, it is just test place)

Wow, you were right all along. Turns out I was overcomplicating things this whole time and I should of just settled with this.

hit.Parent.Humanoid.JumpPower = 0.1
wait(0.1)
hit.Parent.Humanoid.Jump = true
wait(0.1)
hit.Parent.Humanoid.JumpPower = 0

This should be fixed once and for all, but I might come back to this topic if I encounter problems again (Let’s hope not)

1 Like

Also you can wrap that in a coroutine so the wait() doesn’t delay the other parts of the script