-- Function to call on the render step

local function onRenderStep()
	-- Check if the player's character exists and if that character'script
	-- HumanoidRootPart exists
	local character = player.Character
	if character then
		humanoidRootPart = character:FindFirstChild("HumanoidRootPart", true)
		if humanoidRootPart then
			-- Update the position of the camera
			local camRotation = GetCameraRotation(humanoidRootPart)
			local camPosition = humanoidRootPart.CFrame
			camera.CoordinateFrame = GetViewCFrame(camPosition, camRotation)
 
			-- Update the focus of the camera to follow the character
			camera.Focus = humanoidRootPart.CFrame
		end
	end
end -- onRenderStep()