How to force a player left or right?

Currently I am able to detect the direction a player is moving in, and I have added the ability to dash with Q

In order to move the player I use a body velocity. I am aware that setting the velocity to the lookvector of the cframe of the humanoid root part and then multiplying it by X moves them forward a certain amount and dividing by X moved them backwards.
push.Velocity = HRP.CFrame.LookVector * 40

However my pea brain cannot figure out what I could do to make them move left or right instead. Any clues?

You can use the same kind of thing as moving forwards only add rotation to it to change which way the force is going.

Replace OrientationX/Y/Z with what you need

how adding in degrees looks

push.Velocity = (HRP.CFrame.LookVector  * CFrame.Angles(math.rad(Orientation.X),math.rad(Orientation.Y),math.rad(Orientation.Z))) * 40
1 Like

Thanks but this line errored for me. I found that push.Velocity = (HRP.CFrame * CFrame.Angles(math.rad(X),math.rad(Y),math.rad(Z))).LookVector * 40 worked instead

1 Like