Walking animation not smooth

I implemented a walking script that plays an animation when the player moves. But whenever the player stops and starts moving again—or rapidly presses movement keys like W, A, S, or D—the animation snaps back to the beginning instead of continuing smoothly. It makes the animation seem kinda unnatural, any way to fix this?


this example shows me spamming the D key

local walkAnimationId = "117732757115316"

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local walkAnimation = Instance.new("Animation")
walkAnimation.AnimationId = "rbxassetid://" .. walkAnimationId

local walkTrack = humanoid:LoadAnimation(walkAnimation)

humanoid.Running:Connect(function(speed)
	if speed > 0 then
		if not walkTrack.IsPlaying then
			walkTrack:Play()
			walkTrack:AdjustSpeed(0.5)
			walkTrack:AdjustWeight(1,0.3)
		end
	else
		if walkTrack.IsPlaying then
			walkTrack:Stop(0.25)
		end
	end
end)
2 Likes

We need to see your script to see what’s happening there.
Copy/Paste it here and put 3 backticks before and after it so it formats properly.

whoops forgot the script, my bad

do u have an idle animation playing? or something that’s looped that’s constantly playing

the default roblox idle animation

whats ur animation priority

local players = game:GetService("Players")

local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait() :: Model
local humanoid = character:FindFirstChildOfClass("Humanoid") :: Humanoid
local animator = humanoid:WaitForChild("Animator") :: Animator

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://117732757115316"

local track = animator:LoadAnimation(animation) :: AnimationTrack

local resetTimeoutTime = 1 :: number

local lastTimePosition = 0 :: number
local lastTimeout = 0 :: number

humanoid.Running:Connect(function(Speed: number)
	
	local currentTime = tick() :: number
	
	if Speed > 0 and not track.IsPlaying then
		
		if currentTime > (lastTimeout + resetTimeoutTime) then
			lastTimePosition = 0
		end
		
		track:Play()
		track:AdjustSpeed(0.5)
		track:AdjustWeight(1, 0.3)
		track.TimePosition = lastTimePosition
	elseif track.IsPlaying then
		
		lastTimePosition = track.TimePosition
		lastTimeout = currentTime
		
		track:Stop(0.25)
	end
end)

try this

1 Like