Help with a way to force the player to move

Hello, I need help with a script that will force the player to move towards the players LookVector constantly. Something like this;


But faster and able move towards the LookVector of the player when the player turns. This is this code for the forced movement I’ve made so far.

		local BodyVelocity = Instance.new("BodyVelocity",HumanoidRootPart)
		BodyVelocity.MaxForce = Vector3.new(10000,0,10000)
		BodyVelocity.Velocity = HumanoidRootPart.CFrame.lookVector*24

Don’t use BodyVelocity, it’s deprecated. Very sad moment.

Also, I recommend using Humanoid:Move(Vector3) as that will cause the Humanoid to walk in the specified direction from the unit vector. You would need to constantly call that function since the player might walk somewhere else.

2 Likes

Where would I locate the Vector3 to, to make the player move in the humanoidRootParts lookvector ?

3 Likes

I would stick to BodyForce, but use a VectorForce instead, it works basically the same as a BodyVelocity. You wouldn’t be able to use the Humanoid:Move() function because that will be overridden by the characters own movement. (Unless you mess with the default character control scripts which can be very complicated)

1 Like

Switch your code to this:

local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.MaxForce = Vector3.new(10000, 0, 10000)
BodyVelocity.Velocity = HumanoidRootPart.CFrame.LookVector * 24
BodyVelocity.Parent = HumanoidRootPart

local originalOrientation = HumanoidRootPart.Orientation

local connection = nil
connection = game:GetService("RunService").Stepped:Connect(function()
	local newOrientation = HumanoidRootPart.Orientation

	if newOrientation ~= originalOrientation then
		originalOrientation = newOrientation

		BodyVelocity.Velocity = HumanoidRootPart.CFrame.LookVector * 24
	end
end)

BodyVelocity.Destroying:Connect(function()
	connection:Disconnect()
end)
2 Likes