I'm trying to set the camera to a position on player spawn, and this is the code I'm currently using, but sometimes it doesn't actually set the camera to the CFrame of the cameraPart and then resets back to the player's view. Any ideas?
local camera = workspace.CurrentCamera repeat wait () camera.CameraType = Enum.CameraType.Scriptable until camera.CameraType == Enum.CameraType.Scriptable camera.CFrame = workspace.locationA.cameraPart.CFrame
Although the script have several bad practices, I can see what are you trying to do, but the reason why it doesn't work is because Roblox's default script sets the CameraType back to default when the player is fully loaded and the script is trying to set the CameraType before the player is loaded. To avoid this a simple solution would be updating the camera's position to locationA and have the Scriptable CameraType forever:
local camera = workspace.CurrentCamera while wait() do camera.CameraType = Enum.CameraType.Scriptable camera.CFrame = workspace.LocationA.cameraPart.CFrame end