A player facing the wrong direction when teleported

I tried to search the same problem of mine here but I don’t know what it’s called because I’m new at programming.

So, now my problem is when a player touched a brick (A teleporter), It moves the player facing the wrong direction.

Heres my screenshots:
(The Wrong Direction)

(Intended Direction)

3 Likes

So this is my script that uses teleport:

Object.Parent.HumanoidRootPart.CFrame = tpPart.CFrame * CFrame.new(0,10,0)
1 Like

Rotating the tpPart will solve the issue.

1 Like

Did you simply try to rotate the part the player gets Teleported on? That should work.

I’ve tried it but same output happens.

Yes, I’ve tried it but the same output happens.

What way is the surface “Front” facing.

(I put a motor on the front surface) (the x sign was the direction of player when teleported)
So, this is my tpPart brick.

Which face on the brick itself, is facing the direction they’re spawning in?

They’re spawning and facing on the RightSurface of the brick

Okay, I know the problem now…

The teleportation method using CFrame works on 3rd person view but when the player uses the first-person mode it forces the camera to view on how the player facing direction…

Some of my solution (I’m haven’t done of this thing yet but it could be the answer)
-Forcing the player’s camera to rotate.

If someone knew the solution, lend some code please. :heart:
So I can close this topic and will help future developers that have same problem as me. :slight_smile:

5 Likes

Did you ever figure out a solution for this?

(snip code) (sorry needed to add more)

local cam = game.Workspace.CurrentCamera

cam.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
cam.CameraType = “Custom”
cam.CoordinateFrame = CFrame.new(cam.CFrame.Position)
* CFrame.Angles(math.rad(ang), math.rad(pos), math.rad(ang))

note: Both angles would be the same
pos is cam aim 0 - 360

Thanks to this snippet of code, I made an exact solution to this problem: forcing the camera to face based on the part’s orientation in the Y axis.

Server script (Touch event)

// Parts
local a = script.Parent.A
local b = script.Parent.B

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local ForceLookTelerportEvent = ReplicatedStorage:WaitForChild("ForceLookTeleportEvent")

local cd = false // Cooldown or Debounce
a.Touched:Connect(function(touch)
	if cd == false then
		cd = true
		
		local char = touch.Parent
		local isPlayer = Players:GetPlayerFromCharacter(char)
		if isPlayer then
			ForceLookTelerportEvent:FireClient(isPlayer, b.Orientation.Y)
			char.HumanoidRootPart.CFrame = b.CFrame * CFrame.new(0, 2, 0)
		end
		
		task.wait(1)
		cd = false
	end
end)

LocalScript inside PlayerScript (to communicate with RemoteEvent):

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Camera = game.Workspace.CurrentCamera

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local ForceLookTelerportEvent = ReplicatedStorage:WaitForChild("ForceLookTeleportEvent")

ForceLookTelerportEvent.OnClientEvent:Connect(function(y)
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CameraSubject = LocalPlayer.Character.Humanoid
	Camera.CFrame = CFrame.new(Camera.CFrame.Position) * CFrame.Angles(math.rad(0), math.rad(y), math.rad(0))
	Camera.CameraType = Enum.CameraType.Custom
end)

P.S: Sorry I was a bit late to reply because of my hectic College schedule >_<

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