Obby Camera Orientation

Any ideas on how to do this as I want it so when I die the camera only moves the y camera orientation from the checkpoint and the x,z staying the same so I dosen’t make my camera look the other way and make players go backward ? (it’s for an obby )

local module = {}

local player = game:GetService("Players").LocalPlayer
local character = player.Character
local checkpoints = workspace.Stages.checkpoints
local camera = workspace.CurrentCamera

function plr()
	if player then 
		repeat wait() until player.Character:FindFirstChild("HumanoidRootPart")
		local checkpointsFolder = checkpoints:WaitForChild(tostring(player.leaderstats.stage.Value))
		if checkpointsFolder then 
			local arrowMesh = checkpointsFolder:FindFirstChild("Meshes/arrow")
			local camera = workspace.CurrentCamera

			if arrowMesh and camera then
				local arrowCFrame = arrowMesh.CFrame
				local _, yRotation, _ = arrowCFrame:ToEulerAnglesXYZ()
				local cameraPosition = camera.CFrame.Position
				camera.CFrame = CFrame.new(cameraPosition) * CFrame.Angles(0, yRotation, 0)
				player.Character.HumanoidRootPart.CFrame = arrowCFrame + Vector3.new(0, 3, 0)
			end
		end
	end    
end
if player.Character then
	wait()
	plr()
end

player.CharacterAdded:Connect(function()
	wait()
	plr()
end)

return module
3 Likes

Have you tried changing CameraType to scriptable when changing it CFrame?

1 Like

if it’s on fixed it dosen’t work ?

Nope it dosen’t work, it just sets my camera pretty wierd when I die