Animation not updating after being changed

I’ve been working on a crouch animation, and said crouch animation changes the walk/idle animation. However, the animation for idle doesn’t update until I move, and the animation for walking doesn’t update until I stop moving. Does anyone know how to fix this? I’ve tried stopping the player for one frame for the walking animation, but that causes the animation for crouching to glitch.

It’s like the TNT duplication glitch in Minecraft. The TNT is technically powered, but it doesn’t ignite until it is moved, which updates the TNT, causing it to ignite.

Here are some videos of what I mean:

Walking:


As you can see, the walk animation does not change until I stop moving for a good amount of time.

Idle:


As you can see, the idle animation does not change until I move for a good amount of time.

Is this something that is unsolvable, is there a solution to it, and if so, what is it? Also, is this a Roblox bug, or just something that’s supposed to happen? (I have tried stopping the player for exactly one frame, and that works for the walking, but it causes the beginning of the crouch animation to glitch out and make the character lean too far forwards.)

3 Likes

To make a crouch animation, you don’t need to update any animations. Just simply play it and your done. If that was the case, you’d have to update EVERY animation to do a single animation.

After crouching, I want to make the character stay crouched while still allowing them to walk around, and that means that I do in fact have to change the walking/idle animation.

Do something like this:

local char = game.Players.LocalPlayer.Character
script.Parent.MouseButton1Click:Connect(function()-- put a function you want to trigger here
char.Animate.walk.WalkAnim.AnimationId = "whatever your animation id is"
end)

I know how to change the animation, they just don’t update until I do something. For walking, it’s stop walking, for idle, it’s start walking. I want this to happen automatically without needing to do something like stopping the movement for one frame, as that glitches out the crouching animation.

So, do you want to stop the issue when the player is afk they still do the crawl animation?

I want to stop this from happening:

Idle:

Walk:

1 Like

I still don’t get the problem. I don’t see any problem with the walk or idle animation.

The walk animation stays at the default walk animation after crouching, when it should change. It only changes after standing still momentarily.

The idle animation stays at the default idle animation after crouching, when it should change. It only changes after walking momentarily.

What I want is for these to update automatically, without the player having to change their movement.

I think this should work:

-- add a function/ triggering thing here
crouchanim:Play()
char.Animate.walk.WalkAnim.AnimationId = "whatever your animation id is"
-- add a function/ triggering thing here
crouchanim:Stop()
char.Animate.walk.WalkAnim.AnimationId = "change it to roblox's animation id unless you have a custom walk animation"

I already do that.

The problem is that it doesn’t update until the player changes their movement. The animation changes, but doesn’t update automatically.

It’s like the TNT duplication glitch in Minecraft. The TNT is technically powered, but it doesn’t ignite until it is moved, which updates the TNT, causing it to ignite.

Another good example is how floating sand spawns, again in Minecraft. The sand will simply be floating, unaware that it should be falling, until something like a block placing makes the sand update itself, and it checks if it should be falling, and it goes “Oh. I should be falling right now.” It then falls, and then all of the other floating sand around it are updated, and the process is repeated.

char.Animate.walk.WalkAnim.Parent = game.ReplicatedStorage
wait(amount)
char.Animate.walk.WalkAnim.Parent = char

Maybe this will work?

Nope, reparenting it doesn’t change anything, and changing all of the character parts’ parent to the workspace and back to the character sort of works, but it also breaks quite a lot.

hello, you forgot to load the animation again, whenever you change an animation id you should remember to re-load the animation again.

local animation_object = Animation object here
animation_object.AnimationId = "rbxassetid://number here"
local loaded_anim = hum:LoadedAnimations(animation_object)


animation_object.AnimationId  = "rbxassetid://crouch animation id" -- this thing updates the variable.
local loaded_anim = hum:LoadedAnimations(animation_object)--loads the animation once again.

even better to shorten this code:
just basically create a function that handles the animation.

function Animate(thing_to_animate, animationId, animator)
   --first  things off, "thing_to_animate" is the animation object
   --you want the animationid to edit to.
  
   --animationId is basically the id u want to give to the animation object.
   --animator is basically the humanoid to load to or Animator to load to.
   
   thing_to_animate.AnimationId = animationId
   local new_animations = animator:LoadAnimation(thing_to_animate)
   return new_animations 
end
1 Like

:LoadedAnimations() was apparently not a valid member of Humanoid, so I tried this:

loaded_anim = chr.Humanoid:LoadAnimation(chr.Animate.idle.Animation1)
loaded_anim = chr.Humanoid:LoadAnimation(chr.Animate.idle.Animation2)
loaded_anim = chr.Humanoid:LoadAnimation(chr.Animate.walk.WalkAnim)
loaded_anim = chr.Humanoid:LoadAnimation(chr.Animate.run.RunAnim)

Which changed absolutely nothing.

Full Script
local animEvent = script.Parent:WaitForChild("CrouchEvent")
local player = game.Players.LocalPlayer
local team = player:WaitForChild(player.Name .. "_Team")
local crouching = false
local crouchAnim = game:GetService("ReplicatedStorage").Animations.Crouch
local unCrouchAnim = game:GetService("ReplicatedStorage").Animations.UnCrouch
local loaded
local debounce = false
local chr
local loaded_anim

local heightScale

local TweenService = game:GetService("TweenService")
local TweenInfo = TweenInfo.new(0.6, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local crouchTween

animEvent.Event:Connect(function()
	if team.Value == "Survivor" and crouching == false and debounce == false then
		chr = player.Character
		
		debounce = true

		crouching = true
	
		loaded = chr.Humanoid:LoadAnimation(crouchAnim)
		loaded:Play()
		
		chr.Animate.idle.Animation1.AnimationId = "rbxassetid://6947538908"
		chr.Animate.idle.Animation2.AnimationId = "rbxassetid://6947538908"
		chr.Animate.walk.WalkAnim.AnimationId = "rbxassetid://6947559461"
		chr.Animate.run.RunAnim.AnimationId = "rbxassetid://6947559461"
		
		loaded_anim = chr.Humanoid:LoadAnimation(chr.Animate.idle.Animation1)
		loaded_anim = chr.Humanoid:LoadAnimation(chr.Animate.idle.Animation2)
		loaded_anim = chr.Humanoid:LoadAnimation(chr.Animate.walk.WalkAnim)
		loaded_anim = chr.Humanoid:LoadAnimation(chr.Animate.run.RunAnim)
		
		crouchTween = TweenService:Create(chr.Humanoid, TweenInfo, {HipHeight = chr.Humanoid.HipHeight / 2.5})
		crouchTween:Play()
		
		print "Crouching"
		
		wait(0.6)
		
		chr.Humanoid.WalkSpeed = 11.25
		
		debounce = false
	elseif team.Value == "Survivor" and debounce == false then
		debounce = true
		
		crouching = false
		
		loaded = chr.Humanoid:LoadAnimation(unCrouchAnim)
		loaded:Play()
		
		chr.Animate.idle.Animation1.AnimationId = "rbxassetid://6982673549"
		chr.Animate.idle.Animation2.AnimationId = "rbxassetid://6982673549"
		chr.Animate.walk.WalkAnim.AnimationId = "rbxassetid://6943155748"
		chr.Animate.run.RunAnim.AnimationId = "rbxassetid://6943155748"
		
		loaded_anim = chr.Humanoid:LoadAnimation(chr.Animate.idle.Animation1)
		loaded_anim = chr.Humanoid:LoadAnimation(chr.Animate.idle.Animation2)
		loaded_anim = chr.Humanoid:LoadAnimation(chr.Animate.walk.WalkAnim)
		loaded_anim = chr.Humanoid:LoadAnimation(chr.Animate.run.RunAnim)
		
		crouchTween = TweenService:Create(chr.Humanoid, TweenInfo, {HipHeight = chr.Humanoid.HipHeight * 2.5})
		crouchTween:Play()
		
		print "Not Crouching"
		
		wait(0.6)
		
		chr.Humanoid.WalkSpeed = 18
		
		debounce = false
	end
end)

LoadedAnimations() seems weird, as in misstype?
are you referring to “LoadAnimation() is not a valid member of humanoid”? bcuz if so that’s impossible to show rarely; are you probably referring to “attempt to index nil with LoadAnimation()”?

if not neither of those two. then you had some misspell on your script.
LoadedAnimation() should be LoadAnimation()

EDIT: i found out; your loaded color looks blue so this mean it’s called as function not variable you should change the name into this: loaded_anim

1: loaded is not blue in Studio, only on the forum. Not sure why.
2: The loaded animations thing came from this:

3: The load animation thing changed nothing from the OP, not the loadedanimations test.

Oh, then change LoadedAnimations to LoadAnimation

I did. That’s the test that changed nothing from the OP.