Camera sometimes gets ruined

Hello developers! I hope you are having a great day!


The Problem:

About 25% of the time, this happens:


However, here is what happens 75% of the time:

The 75% of the time should be the thing that happens.


The Code

repeat wait() until game:IsLoaded()

local Camera = workspace.CurrentCamera
local Player = game:GetService("Players").LocalPlayer

local char = Player.Character or Player.CharacterAdded:Wait()

Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = game.Workspace.CameraPart.CFrame

I really don’t understand why this is happening. If you can help, please let me know. Thanks! WE

if not game:IsLoaded then
    game.Loaded:Wait()
end

local Camera = workspace.CurrentCamera
local Player = game:GetService("Players").LocalPlayer

local char = Player.Character or Player.CharacterAdded:Wait()

Camera.CameraType = Enum.CameraType.Scriptable
print(Camera.CameraType)

repeat 
    wait()
    Camera.CFrame = game.Workspace.CameraPart.CFrame
until Camera.CFrame == workspace.CameraPart.CFrame

Maybe try this?

Huh strange. It doesn’t work.

and yes it printed.
image

Gonna add more prints.


Edit

The camera does set according to my print(). Weird…

local camera = workspace.CurrentCamera
local cam = game.Workspace.CameraPart
camera.CameraType = Enum.CameraType.Scriptable
local step = game:GetService("RunService").RenderStepped:Connect(function()
    camera.CFrame = cam.CFrame
end)

--To Stop
camera.CameraType = Enum.CameraType.Custom
step:Disconnect()
1 Like