Camera manipulation not working

Hello! I’m making a cutscene which basically shows the ROBLOX game’s world, and after you choose your team it stops and you can view your main character again. Here is the code:

local chooseteam = game.Workspace.Haschosenteam
wait(2)
while true do

	local cam = workspace.CurrentCamera
	local focuspart = game.Workspace.FocusPart
	
	cam.CameraType = "Attach"
	cam.Focus = focuspart.CFrame
	cam.CameraSubject = focuspart
	wait(0.1)
	if chooseteam.Value == true then
		print("This part works")
		cam.CameraType = "Custom"
		break
	end
end

It does print “This part works”, however a split second after you respawn, you go back to the cutscene part. Why is it not working?

You should look into using the TweenService for camera movement

Edit: If this is in a screen GUI then turn off ResetOnSpawn in the GUI properties