I have this CFrame that is used to teleport a player to a specific block when they die, however, when they are teleported to the block, the are facing backwards to the direction I want them to be facing. How would I fix this?
Instead of adding 90 to TempCheckpoint.Orientation.Y, you should subtract it by 90. This should face the player in the opposite direction that you’re experiencing at the moment.
That’s interesting… Let’s try replacing the entire line with this one line: char:SetPrimaryPartCFrame(CFrame.new(TempCheckpoint.Position + Vector3.new(0, 3, 0)) * CFrame.Angles(0, TempCheckpoint.Orientation.Y + 90, 0) * CFrame.Angles(0, math.pi, 0))
If this doesn’t work, then it sounds like something physics-related is causing the player to forcibly turn in that direction. Out of curiosity, would it be possible to rotate the TempCheckpoint so that it’s facing the opposite direction, causing the player to face the way you want?
ok, so I rotated the brick, and used that code, and now it mostly works. The new issue is that the camera didnt swap, so you teleport looking at your self in third person. Do you happen have any idea how to fix that?
If you want to make it to where every time the player is teleported their camera is facing forward, you’ll need to add another script on the Client side as the player’s camera can’t really be manipulated by the Server.
I would create a RemoteEvent and put it in ReplicatedStorage. Name it ReadjustCamera.
Next, I would insert a LocalScript into the StarterGui with the following:
local RS = game:GetService("ReplicatedStorage")
local Remote = RS:WaitForChild("ReadjustCamera") -- The name of the remote event
Remote.OnClientEvent:Connect(function()
local camera = workspace.CurrentCamera
local char = game.Players.LocalPlayer.Character
camera.CFrame = char.Head.CFrame
end)
Then, after the code that teleports above, enter this: (player is the name of the PlayerObject. I assume since you have a char, you have a player to pass through the remote like below)
I marked this as the solution because it got it mostly working, it is still finicky with the rotation being off for some orientations, but I will see if I can figure that out
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Head = Character:WaitForChild("Head")
local Camera = workspace.CurrentCamera
local RS = game:GetService("ReplicatedStorage")
local Remote = RS:WaitForChild("ReadjustCamera")
Remote.OnClientEvent:Connect(function()
Camera.CFrame = Head.CFrame
end)
Change it to this though, to avoid redeclaring the same constants (variables with unchanging values) each time the event is fired and the connected callback function is subsequently executed.