Make Body Velocity move with HRP

I want to make it so that the body velocity direction will always be the direction the player is facing. For example it is moving forward, but if i turn to the left with shiftlock the velocity will be into that direction to, basically moving in the direction im facing. Here’s the current code. It runs in the server

local WVelocity = Instance.new("BodyVelocity",Player.Character.HumanoidRootPart)
			WVelocity.MaxForce = Vector3.new(30000, 0, 30000)
			game.Debris:AddItem(WVelocity,1)
			WVelocity.Velocity = (Player.Character.HumanoidRootPart.CFrame.LookVector * 70)```
1 Like

Does the code you provided work currently, or no?

If not - I assume it’s because you need to have some sort of loop or rapid firing event to change the direction of the velocity so it always is in the direction the player is looking.

for example:

game:GetService("RunService").HeartBeat:Connect(function()
    WVelocity.Velocity = (Player.Character.HumanoidRootPart.CFrame.LookVector * 70)
end)

Also, you may wish to move it to the client in order to reduce the load on the server, especially if you have multiple players in the server.

2 Likes

any way to do this without a loop?

2 Likes

Not that I can think of.

1 Like

If im not wrong BodyVelocity is deprecated… So this wont work. You could try using VectorForce tho!

1 Like

vector force is laggy :sob: it only works smoothly if you set the network owner

1 Like

How is it laggy??? Still you cant use BodyVelocity anymore.

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