CFrame make player face the opposite way

Hello, i made a script which teleports a player right next to the other in front, however the player faces him, i want it so the player faces exactly the opposite way

    local LastTargetPosition = humanoid.RootPart.CFrame
	local Length = 1 -- Length between player and target player
	captorhumamnoid.RootPart.CFrame = LastTargetPosition + LastTargetPosition.LookVector * Length
	captorhumamnoid.RootPart.CFrame = CFrame.new(captorhumamnoid.RootPart.CFrame.Position) Vector3.new(LastTargetPosition.Position.X, captorhumamnoid.RootPart.CFrame.Position.Y, LastTargetPosition.Position.Z))

image

You could try multiplying by Player 2’s orientation.

--hrp1 and hrp2 are player 1 and player 2's HumanoidRootParts, respectively
--targetPos is your target position, not CFrame
hrp1.CFrame = CFrame.new(targetPos) * CFrame.fromEulerAnglesXYZ(hrp2.CFrame:ToEulerAnglesXYZ())

That’ll keep both players facing the same direction, just like the image describes.

Hello for some reason this happens im not sure what i have done wrong
image

local LastTargetPosition = humanoid.RootPart.CFrame
	local Length = 1 -- Length between player and target player
	captorhumamnoid.RootPart.CFrame = LastTargetPosition + LastTargetPosition.LookVector * Length
	character.HumanoidRootPart.CFrame = CFrame.new(LastTargetPosition) * CFrame.fromEulerAnglesXYZ(captorcharacter.HumanoidRootPart.CFrame:ToEulerAnglesXYZ())

nvm my mistake i kept the wrong line with it

local LastTargetPosition = humanoid.RootPart.CFrame
	local Length = 1 -- Length between player and target player
	--captorhumamnoid.RootPart.CFrame = LastTargetPosition + LastTargetPosition.LookVector * Length
	captorhumamnoid.RootPart.CFrame = CFrame.new(captorhumamnoid.RootPart.CFrame.Position, Vector3.new(LastTargetPosition.Position.X, captorhumamnoid.RootPart.CFrame.Position.Y, LastTargetPosition.Position.Z))
	character.HumanoidRootPart.CFrame = CFrame.new(LastTargetPosition) * CFrame.fromEulerAnglesXYZ(captorcharacter.HumanoidRootPart.CFrame:ToEulerAnglesXYZ())

That’s because you’re passing the entire CFrame, not the position. Pass the CFrame.Position value of your target to CFrame.new. Right now, you’re passing the entire CFrame, which is causing the error.

still doesnt work, wont even teleport the player

local cframeInFrontOfPlayer = LastTargetPosition * CFrame.new(0, 0, -1)
1 Like

Yoo finally this worked thank u!

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