I'm trying to create a walk animation script, it's going pretty well, except whenever I change direction (with WASD, not with the arrow keys) the animation restarts and then it looks fidgety Here's the script:

Char = script.Parent print(script.Parent.Name)
human = Char.Humanoid
--declaring the animations
local WalkAnim = Instance.new("Animation", Char)
local JumpAnim = Instance.new("Animation", Char)
local FallAnim = Instance.new("Animation", Char)
print(WalkAnim, JumpAnim, FallAnim)
WalkAnim.AnimationId = "rbxassetid://(ID)"
JumpAnim.AnimationId = "rbxassetid://(ID)"
FallAnim.AnimationId ="rbxassetid://(ID)"
WalkAnimTrack = human:LoadAnimation(WalkAnim)
JumpAnimationTrack = human:LoadAnimation(JumpAnim)
FallAnimationTrack = human:LoadAnimation(FallAnim)
local function OnRunning(speed)
        wait(0.1)
	if speed > 10 and speed < 16 then
	WalkAnimTrack:Play()
	else
	WalkAnimTrack:Stop()
	end
end

human.Running:connect(OnRunning)
human.Strafing:connect(OnRunning)

At first, I thought it had to do with strafing, but that was a different thing. I tried using some waits here and there (but now I've realized those were pointless because i'm trying to get the animation track to wait for the animation to finish before it can restart/play it again).

1 comment

0

I think you should use Debounce: http://wiki.roblox.com/?title=Debounce