ActivateCameraController did not select a module randomly occurs and ruins everything

Hey guys,
So I am making a starting screen of the game, it works well until sometimes this random error occurs.
What I do is to set the camera type to Enum.CameraType.Scriptable and then setting the CFrame of the camera.
It works flawlessly most of the time but randomly bugs which is just so annoying.
How can I fix it?
LocalScript in starterpack:

--anirudh851
local plr = game.Players.LocalPlayer
local char = plr.Character
local camera = workspace.CurrentCamera
repeat wait()
	camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
if workspace:FindFirstChild("StartingCameraPos") then
	repeat wait()
		camera.CFrame = workspace.StartingCameraPos.CFrame
	until camera.CFrame == workspace.StartingCameraPos.CFrame
else
	repeat wait()
		workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
	until workspace.CurrentCamera.CameraType == Enum.CameraType.Custom
	camera.CFrame = camera.CFrame
	camera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
end

Thanks!

Try putting this above everything?

local RunService = game:GetService("RunService")
if camera.CameraSubject == nil then
    repeat RunService.RenderStepped:Wait() until camera.CameraSubject ~= nil
end

Credit to @EmbatTheHybrid

1 Like

The error isnt there after adding this, so marking as solution. If it comes in the future ill inform, thanks!

1 Like