How do I move the HumanoidRootPart forward?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to be able to make the HumanoidRootPart dash in front really quickly. like this photo

  1. What is the issue? Include screenshots / videos if possible!

Putting the position of a bodyposition mover to Vector3.new(0,0,-30) will simply make the humanoid rootpart move -30 degrees on the z axis and not propel the character forward at times.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried to use bodyposition but simply placing the position’s vector3 value to -30 does not propel it forward. I tried to use the LookVector of the HumanoidRootPart’s CFrame, but it makes me go sideways sometimes and forwards other times. Any help is appreciated.

What about using :ApplyImpulse ?

are you trying to make something like a dash ability?

You can do Vector3:Dot() I think.

Try this code I just wrote up.

local TweenService = game:GetService("TweenService")

local humanoidrootpart = 0 --path.to.root.part

local speed = 40 
local _time = 0.4

local walkspeed = 16 -- assumed 16

local function dash()
	local velocity = Instance.new("LinearVelocity")
	local attachment = Instance.new("Attachment")
	
	local movement = nil
	
	attachment.Parent = humanoidrootpart
	velocity.Attachment0 = attachment
	
	-- if you want them to be able to turn
	velocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
	movement = -Vector3.zAxis * speed -- fancier way
	--[[ if you don't...
	velocity.RelativeTo = Enum.ActuatorRelativeTo.World
	movement = humanoidrootpart.CFrame.LookVector * speed ]]
	
	-- if you don't want them to jump
	velocity.MaxForce = 10000
	
	--[[ if you do...
	velocity.ForceLimitMode = Enum.ForceLimitMode.PerAxis
	velocity.MaxAxesForce = Vector3.new(10000, 0, 10000) - doesn't apply force on the y  ]]
	
	velocity.VectorVelocity = movement
	
	local tween = TweenService:Create(velocity, TweenInfo.new(_time), { VectorVelocity = 
		movement.Unit * walkspeed -- end the tween at normal speed
	}):Play()

    task.delay(_time, function()
		attachment:Destroy()
		velocity:Destroy()
	end)
end

Make sure to set the humanoid’s walkspeed to 0 for more accurate results.

I HAVEN’T TESTED THE CODE!!

HumanoidRootPart:ApplyImpulse(HumanoidRootPart.CFrame.LookVector * 1000)
1 Like

This won’t be a high quality dash, it will most likely look like a laggy push, and it will deaccelerate too fast to be able to react to. It will also be inconsistent based on what you’re standing on or what direction you’re moving.

The advantage of using ApplyImpulse is how easy to use it is and the reaction time, it instantly apply a force to the object while it is not the case with the linear velocity (0.05 - 0.2s delay).

There is nothing “laggy” but i aggree with the fact that it deaccelerate too fast, that’s why you should edit the physical properties of all character body part so it look better and the movement is smoother.

This is actually untrue. LinearVelocity attempts to maintain the exact velocity that’s described by it’s property. It instantly obtains that velocity if the max force is set high enough (I’d recommend 100000-1000000).

I’m not talking about the time it take to reach the velocity, but mostly the time it take to setup the instances each time you’re doing a dash, and when people do it server side (which i see often), the velocity have a delay to start and stop depending of the server performance and player network.

The delay is also noticed when you rotate your character at the last moment.
Changing direction around 0.1s before the dash isn’t taken into account so the velocity still is at the last direction and it result to you dashing in the wrong direction, even if it is made on client side.

This isn’t true either, Luau is very fast, I will benchmark the code and show you. After all, it’s better to do it on the client.

I ran the function many times, and benchmarked it. Here’s the code I used:

local a = os.clock()

dash()

print(os.clock() - a)

It’s a 10000th of a second.

client to server replication delay, not delay from making an instance

This script is intended to run on the client. Running dashes on the server will never work smoothly, or fast.

Many tutorials on this. This one is a bit outstanding
Roblox How To Make A Sliding Ability with Mobile Support

This is good. I have used it and it works. Will try to use bodyalign or whatever it is though if ApplyImpulse does have problems like Den_vers says. This thread is considered solved.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.