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.
So I can close this topic and will help future developers that have same problem as me.
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 >_<