Movement System

Hello!

I am trying to create a movement system for my game. RN I have momentum working for when you’re moving. However, when I stop my character stops instantly. How would I go about making the character slowly stop and not stop instantly?

Here’s my code so far:

local Player = script.Parent
local Hum = Player:WaitForChild("Humanoid")

while true do wait()
	if Hum.MoveDirection == Vector3.new(0, 0, 0) then
		Hum.WalkSpeed = 0
		print("Back Momentum")
	else
		if Hum.WalkSpeed < 6 then
			Hum.WalkSpeed += 0.4	
			print("Start Move")
		elseif Hum.WalkSpeed < 12 then
			Hum.WalkSpeed += 0.15
			print("End Move")
		else
			print("Move Cap")
		end
	end
end

Here’s a video:

Any and all help would be appreciated!

1 Like

You could do 2 methods. Use bodymovers like LinearVelocity or BodyVelocity to make continuous velocity and slowly Lerp() it to Vector3.zero, or make the movedirection of the humanoid always the last direction until the walkspeed is 0.