I’m gonna assume that when your player touches the door, they teleport to the other side. And you’re having trouble because after teleporting, the player is facing the direction they were initially looking at before touching the door.
Something like this:
What I assume you want to achieve is something like this:
From what I know, camera manipulation doesn’t work in server scripts and only in local scripts. (Correct me if I’m wrong). If it was only a single door, I would recommend making a local script. However, you have multiple doors. Local scripts still work but you would have to duplicate them and set their properties to their respective doors which is kind of tedious.
What I’d suggest is making a remote event under ReplicatedStorage. Use the CollectionService to tag your doors and give all your tagged doors the server script you’ve created for them. Make sure that upon interaction, the script uses :FireClient(player). If it’s a touch event, don’t forget to use :GetPlayerFromCharacter(). The script would look something like this:
(db = debounce, added to prevent spam teleportation)
local door = script.Parent
local db = false
local camera = workspace.CurrentCamera
local doorevent = game:WaitForChild("ReplicatedStorage").touchdoor
door.Touched:Connect(function(character)
db = true
local player = game.Players:GetPlayerFromCharacter(character.Parent)
character.Parent:SetPrimaryPartCFrame(door.Parent.tp.CFrame + Vector3.new(0, 3, 0))
doorevent:FireClient(player)
task.wait(3)
db = false
end)
(Vector3 is added to prevent the character from spawning inside the teleportation part)
As for the localscript to manipulate the camera, you can just add it under StarterPlayerCharacter. Simply just do .OnClientEvent:Connect(function()). Make sure to change the camera type to scriptable first, then change it back to custom after changing the angle.
Here’s an example:
local plrs = game:GetService("Players")
local plr = plrs.LocalPlayer
local cam = workspace.CurrentCamera
local rs = game:GetService("ReplicatedStorage")
local doorevent = rs:WaitForChild("touchdoor")
doorevent.OnClientEvent:Connect(function()
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = CFrame.new(cam.CFrame.Position) * CFrame.Angles(0, math.rad(90), 0)
cam.CameraType = Enum.CameraType.Custom
end)
If your door is using a proximity prompt instead, the prompt will immediately get your player instead of your character, so you wouldn’t need to use :GetPlayerFromCharacter(). Just simply edit character:SetPrimaryPartCFrame to player.Character:SetPrimaryPartCFrame.
Here’s what it would look like:
local door = script.Parent
local pp = door.ProximityPrompt
local db = false
local camera = workspace.CurrentCamera
local doorevent = game:WaitForChild("ReplicatedStorage").touchdoor
pp.Triggered:Connect(function(player)
db = true
player.Character:SetPrimaryPartCFrame(door.Parent.tp.CFrame + Vector3.new(0, 3, 0))
doorevent:FireClient(player)
task.wait(3)
db = false
end)