How to make character constantly move in the same direction that it is facing

I am trying to make something that lets a player move forward in the direction that they are facing when holding spacebar. Currently, I’m using a body velocity and changing the velocity to the character’s HumanoidRootPart’s lookvector every frame, but it’s pretty laggy when there’s high ping

heres my script:

activated = true
local bv = Instance.new("BodyVelocity", player.Character.HumanoidRootPart)
bv.MaxForce = Vector3.new(1e8, 1e8, 1e8)
bv.Velocity = player.Character.HumanoidRootPart.CFrame.LookVector * 50
bv.Name = "Forward"
	
spawn(function()
	while activated == true do
		bv.Velocity = player.Character.HumanoidRootPart.CFrame.LookVector * 50
		wait()
	end
end)

Is there a better way to do this either with or without using body velocity? (also it doesnt need to keep them up in the air)

Hi, you could use Humanoid:Move(Vector3 moveDirection).

By any chance, is it a server script? If that’s so, there will be replication lag. Not sure about micro-optimizations but try using coroutine. I believe it is slightly better than spawn in one measurement, but many times better in many.

Alternatively, client-side the movement ability and let the server verify its movements.