Need help with using CFrame to move a part to the left

I am trying to make a player move to the left of a car as they get out. For some reason depending on the orientation of the car, the player will either get out to the left, right, back, front, etc?

This is the line that runs when the player exits:
char:SetPrimaryPartCFrame(CFrame.new(RootPart.Position + Vector3.new(-8,0,0)))

This is what happens:

I thought the CFrame was set up properly so that it will always move to the left by 8 studs but it doesn’t.
I have already tried switching out :SetPrimaryPartCFrame with just changing the root part’s CFrame but didn’t help?

Are you sure the :SetPrimaryPartCFrame() is getting executed at the right time?

To transform a CFrame in object space multiply it by another CFrame.

char:SetPrimaryPartCFrame(RootPart.CFrame * CFrame.new(-8, 0, 0))

This should put ‘char’ 8 studs to the left of ‘RootPart’ regardless of it’s rotation.

2 Likes

When you change orientation the direction of “left” changes, so to fix this you need to use the RightVector of the vehicle or player, and multiply it by -8

char:SetPrimaryPartCFrame(CFrame.new(RootPart.Position + (RootPart.CFrame.RightVector * -8)))

Thanks, it worked for me perfectly!