Forcing player character to face certain direction

I want to make so the player faces a certain direction on button press so then I can play an animation.

I’m making a dodge system for a top view shooter, everything almost done expect animation.

My other scripts require AutoRotate to be disabled and dodge is using walk speed 0 to “disable” player movement while BodyForce pushes the player around.

I was trying to mess around with vectors and body gyros but I just can’t quite figure it out.
So I’m asking for help in understanding it or at least make a way to make it work.


I can’t find a question in what you posted.

So which is it? Is it done… or…?

1 Like

fixed it.
my main problem is this damn bodygyro,
I know that you can make them follow parts but that ended up in trashbin after my poor implementation.
Then I readout that you can set up the direction or an angle manually and that’s what I need help with.

So you want to know how to make the character follow the mouse and rotate to it using BodyGyro?

Not mouse,
I want player to turn at certain angle.

Which angle…? It looks like it’s already turning, so I am still confused a bit. What do you want to happen, exactly, and caused by what?

I want to set up a separate gyro that activates after special input lets say after pressing D player would go to the right side of the screen, problem is I don’t know how to make character face a direction that player is now moving towards.

at least not without auto rotate

if it still isnt clear, here is a video of how it should act.

I’m just going to attempt a solution, because I still have only like 70% idea of what you’re talking about.

What is it currently coded to do? What code is rotating them right now?

As of now its a humanoid, script disables all inputs and tells player character to move 15 studs in one direction. it turns on auto rotate for a moment then it gets disabled again, and I want to achieve similar transmission but with the use of bodygyro.

its a scraped code but i want to port this effect

Oh that’s a rather interesting way to do that :thinking: But uhh… prone to issues.

Here’s an example of making them face right using whatever body gyro you have. It requires the camera to be present. This is based on your current top-down camera setup.

You’ll have to make sure all the variables are defined properly below.

local facingRightDirection = camera.CFrame:VectorToWorldSpace(,0,0) )
local currentPosition = humanoidRootPart.Position
local targetPosition =
	currentPosition.X + facingRightDirection.X * 100, 
	currentPosition.Z + facingRightDirection.Z * 100
gyro.CFrame =, targetPosition)

I cant figure out camera wariable mind expanding on it ?
p.s. that code was not writen by me. other programer wrote it from scratch to somewhat show me how i could make a dodge system.

Which camera variable? The world space one?

it should read like this, right ? local camera = workspace.CurrentCamera

From a LocalScript, sure. Have you ever scripted before? It might be tough to understand code if you haven’t done some simpler things yet.

yea, but I’m getting an error “VectorToWorldSpace is not a valid member of Camera”
never did anything bassed of camera expect that simple top view.

Right, sorry. It should be

local facingRightDirection = camera.CFrame:VectorToWorldSpace(,0,0) )

Good old debuging. now it says “invalid argument #1 (Vector3 expected, got number)”

at line — currentPosition.X + facingRightDirection * 100,

I edited my script above. I was missing the .X and .Z after the facingRightDirection usages.

1 Like