How do I make the player’s camera be facing the same way that the character itself if facing? For my obby, players are spawned in at a checkpoint and their character will have the same orientation as the checkpoint (note that the checkpoint is a BasePart and not a SpawnLocation!). However, even though their character’s orientation is the same as the checkpoint, the camera does not move to behind the player when the character’s orientation has been changed.
So basically, I want the camera to be behind the player when they spawn in, but I want the players to still be able to freely move around their camera after they’ve spawned in.
local Run = game:GetService("RunService")
local Character = game.Players.LocalPlayer.Character
Run.RenderStepped:Connect(function()
local CharCF = Character.PrimaryPart.CFrame
local CamLook = workspace.CurrentCamera.CFrame.LookVector *100
Character:SetPrimaryPartCFrame(CharCF.p,Vector3.new(CamLook.X,CharCF.p.Y,CamLook.Z)
end)
local Character = script.Parent
local Camera = workspace.CurrentCamera
local RunService = game:GetService("RunService")
Camera.CameraSubject = Character.Head
Camera.CameraType = Enum.CameraType.Attach
local function OnUpdate()
if Character and Character:FindFirstChild("Humanoid") then
Camera.CFrame = CFrame.new(Character.Head.Position) * CFrame.new(0,0,10)
end
end
RunService:BindToRenderStep("Camera",Enum.RenderPriority.Camera.Value, OnUpdate)
What this will do is it checks the HumanoidRootPart’s direction its looking & apply the same to the camera. for example if it’s looking directly at Z+, then the camera’s LookVector will be 0,0,1
I haven’t tested this so if anything doesn’t work, try adding .Unit after the LookVector on the third line