Animation freaks out when turning

So ive created this code that plays my animation. When im standing still the idle animation works fine, when i walk in a straight line the walking animation works fine.

But when i start turning it just freaks out, is there anybody that has experience with animations and knows how to fix this?

Please let me know

local WalkAnimation = script:WaitForChild("Walk")
local IdleAnimation = script:WaitForChild("Idle")

local character = script.Parent
local player = game.Players:GetPlayerFromCharacter(character)
local humanoid = character.Humanoid

local WalkAnimationTrack = humanoid.Animator:LoadAnimation(WalkAnimation)
local IdleAnimationTrack = humanoid.Animator:LoadAnimation(IdleAnimation)

humanoid.Running:Connect(function(speed)
    if speed <= 0.1 then
        IdleAnimationTrack:Play()
        WalkAnimationTrack:Stop()
    elseif speed > humanoid.WalkSpeed / 2 then
        WalkAnimationTrack:Play()
        IdleAnimationTrack:Stop()
    end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Perhaps you can use humanoid:GetPropertyChangedSignal("MoveDirection") to check if the character is moving or not. If the MoveDirection is 0,0,0 then it’s not, if else then it is.

What if you stop the idle animation first, then play the walk animation?
Also, when your character turns, their speed probably drops below 0.1 so try raising it to if speed <= 0.5 to see if it makes a difference. If it does then keep decreasing it from 0.5 to 0.4 and then lower until the issue happens again so you know the limit.

Ive increased it all the way up to 1 but doesnt make a difference…

Then try a value stupidly higher, something like 10.

Did you change the start/play order of the animations too?

Yea i changed that order like u told me, ill increase it a bit more let me test.

Well i increased itall the way up to 10 but nothing changed?

How would i use this? Im not really sure

your issue is that you are spam playing the animation

humanoid.Running:Connect(function(speed)
	if speed <= 0.1 then
		IdleAnimationTrack:Play()
		WalkAnimationTrack:Stop()
	elseif speed > humanoid.WalkSpeed / 2 then
		if WalkAnimationTrack.IsPlaying == false then
			WalkAnimationTrack:Play()
		end
		IdleAnimationTrack:Stop()
	end
end)
humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
    if humanoid.MoveDirection==Vector3.new(0,0,0) then
        -- The character is Idle
    else
        -- The character is moving
    end
end)

This worked really well (forgot to response) Thanks for helping me out!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.