Player Facing Wrong Way

Now it just looks like the first screenshot I sent where the player is facing to the left. He’s not upside-down anymore though.

Try this out

char:PivotTo(Zones[player:WaitForChild("leaderstats"):WaitForChild("Zone").Value].CFrame * CFrame.Angles(0,math.rad(90),0)

Now the player is upside-down again and still faces the wrong direction. By the way, thanks for helping me work through all of this!

I think I forgot which axis rotates what
char:PivotTo(Zones[player:WaitForChild("leaderstats"):WaitForChild("Zone").Value].CFrame * CFrame.Angles(0,0,math.rad(90))

And no problem, happy to try and help.

Now the character spins in many directions and falls off the edge.

Do you know the front facing direction of the part you want to move to?

Sorry for making you jump around in circles btw.

No problem haha. I’ve got lots of time.

The orientation of the player when it is facing forward (the direction I want it to face) is 0, -90, 0. Does that help?

I think it does, hold on a second I’m going to try something.

char:PivotTo(Zones[player:WaitForChild("leaderstats"):WaitForChild("Zone").Value].CFrame * CFrame.Angles(0,0,math.rad(-90))

Try this out. I didn’t have a frame of reference for my character’s orientation so I had to kinda guess

It doesn’t work, I might know, I am going to try something out.

Okay, but here’s something else just in case.

char.PrimaryPart.CFrame = Zones[player:WaitForChild("leaderstats"):WaitForChild("Zone").Value].CFrame + Vector3.new(0,5,0)

Man I hate CFrames

I still don’t know how to use CFrames haha. It doesn’t work but I’ll keep trying to figure something out. Thanks for your help!

1 Like

@UwUanimsyt was in the right direction. I agree that CFrames can be a pain, but when that’s the case, it’s best to break each part down into a variable first :sweat_smile:

Try this, which I built off of @UwUanimsyt 's code.

If it is turned wrong, the math.rad will need to be changed.

local playerZone = player:WaitForChild("leaderstats"):WaitForChild("Zone").Value

local zoneFound = Zones:FindFirstChild(playerZone)

local offsetPos = zoneFound:GetPivot() + Vector3.new(0,5,0)

local endCFrame = offsetPos * CFrame.Angles(math.rad(90), 0, 0)


char:PivotTo(endCFrame)


playerZone = nil
zoneFound = nil
offsetPos = nil
endCFrame = nil

It isn’t working, but maybe the problem isn’t your script, maybe there is something else within my game causing it. Nonetheless, is there anyway to make the player face the next checkpoint? Maybe that would be the fix.

I’m a bit late to the party so I don’t know if someone already mentioned this but you could do:
char:SetPrimaryPartCFrame(Zones[player:WaitForChild("leaderstats"):WaitForChild("Zone").Value].Position)*CFrame.Angles(0,math.rad(90),0)

Hold on, I believe it does work.

I didn’t know that my LockFirstPerson would be an issue, but when I changed it to classic, it worked.

I need it to be in LockFirstPerson though.

There is, assuming you have the next checkpoints position.

local nextCheckpoint = somepartthinghere

local nextPos = nextCheckpoint.Position
local charPos = char:GetPivot().Position

char.PrimaryPart.CFrame = char.PrimaryPart.CFrame * CFrame.lookAt(charPos, Vector3.new(nextPos.X, charPos.Y, nextPos.Z))

Thanks for the reply, but I believe I has been provided a solution.