Animation skipping when changing slopes?

  1. What do you want to achieve?
    I want to stop this animation from skipping when I climb slopes.

  2. What is the issue?
    I have these custom characters that rely on the code below to play their walking animations.
    I’m VERY new to scripting, all I’m doing is mashing tutorials together to try and get results, so the code isn’t great as far as I can tell.

wait()

local WA = Instance.new("Animation")
local IA = Instance.new("Animation")

WA.AnimationId =  "rbxassetid://6128603903"
IA.AnimationId =  "rbxassetid://5895818559"

local WalkAnim = script.Parent.Humanoid:LoadAnimation(WA)
local IdleAnim = script.Parent.Humanoid:LoadAnimation(IA)

script.Parent.Humanoid.Running:Connect(function(s)
	if s > 0 then
		WalkAnim:play()
		IdleAnim:stop()
	else
		WalkAnim:stop()
		IdleAnim:play()
	end
end)

When my characters start to climb slopes, their animations will reset multiple times until the slope is constant. One of the other characters has constantly skipping animations.

  1. What solutions have you tried so far?
    I looked around in lots of places and lots of forums for answers, but no one seemed to have the same problem. I have a few other scripts, but this is the only one that seems to do anything. The animation is set to movement, it used to be set to core.

I also tried to set the Running:Connect speed to 1, .1, and 12 (his walking speed is 13).
Are my characters just too custom to play animations correctly, or is there something I’m missing?

Thanks in advance for any help! Let me know if it’s asking too much, if someone wants the place file, or if someone asked the same question and I happened to miss it.

Hi @froidmilky, maybe the problem is with your animation? I also have the impression that the bug happens when you fall, could you jump and see if it does the same bug again? If this happens because you are jumping it means that the method you are using to play the animation is not correct / not suitable (since I’m not familiar with animation and how to use it, what I’m telling you might not be true)

I hope this will help you
Otherwise the player model is quite beautiful

1 Like

Thanks for replying!! That’s a good idea, but I’m not sure what I might be doing wrong. I actually had a similar problem when I started up my sprinting animation, I figured out that it was the wait() between the characters’ walking and sprinting states. I tried to remove the wait in both the walk and sprint animations, but that didn’t help.

Suggesting that it was the animation helped me realize I needed a falling animation separate from this. I hopped off a tall block and after a few seconds of falling, the animation would stop. I don’t think this is related though, since I just didn’t animate or script a falling animation at all.

And miigwech! I like doing very custom models. I wish this was a smaller problem, but most of my map is changing slopes, since I used the terrain editor.

I’m not entirely sure, but I think the issue is the fact that you’re playing the walk animation every time the walking speed changes. Perhaps you could try this?

wait()

local WA = Instance.new("Animation")
local IA = Instance.new("Animation")

WA.AnimationId =  "rbxassetid://6128603903"
IA.AnimationId =  "rbxassetid://5895818559"

local WalkAnim = script.Parent.Humanoid:LoadAnimation(WA)
local IdleAnim = script.Parent.Humanoid:LoadAnimation(IA)

local Running = false

script.Parent.Humanoid.Running:Connect(function(s)
	if s > 0 then
		if not Running then
			WalkAnim:play()
			IdleAnim:stop()
			Running = true
		end
	else
		WalkAnim:stop()
		IdleAnim:play()
		Running = false
	end
end)

To clarify, this should make it so the walking animation only plays once when moving from an idle, instead of every time you change speed. (Slopes tend to change your speed a lot)

1 Like

Wow!! That fixed it! Thank youuuuu, I’ll definitely remember this fix. :hearts:

1 Like