Menu screen breaks sometimes (setting camera to scriptable)

This has been an unfortunate huge issue throughout the past, and still continues to this day sadly

Try this perhaps?

local Camera = workspace.CurrentCamera
local focus -- Set your focus thingy here

local CurrentAttempts = 0
local MaxAttempts = 10

while CurrentAttempts < MaxAttempts do
    local success, whoops = pcall(function()
        Camera.CameraType = Enum.CameraType.Scriptable
    end)

    if success then
        print("Successfully changed the Camera's CameraType!")
        Camera.CFrame = focus.CFrame
        break
    else
        CurrentAttempts += 1
    end

    if CurrentAttempts == MaxAttempts then
        warn("Max attempts reached, could not change the Camera Type")
        break
    end

    wait(1)
end
1 Like

The issue ended up still occurring despite using your code. I have no clue what will fix it. How do other games with menu screens not have this issue?

Hey there,

Try yielding for the camera maybe(?) This honestly sounds like a ROBLOX issue though, so maybe there’s not much you can do.

repeat
    task.wait(0.1)
    camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable

camera.CFrame = focus.CFrame
camera.CameraSubject = focus

To reverse it:

repeat
    task.wait(0.1)
    camera.CameraType = Enum.CameraType.Custom
until camera.CameraType = Enum.CameraType.Custom

camera.CameraSubject = game.Players.LocalPlayer:FindFirstChild("Humanoid")

Setting camera’s subject is needed, so the system knows what to focus on. Hope this helped! :slight_smile:

I believe it’s just a matter of yielding when to set the specific Cameras, most people use wait() as a temporary solution but unfortunately that doesn’t really solve the official case

Only other thing I can think of is waiting for all Instances to properly loaded within the client, or using ContentProvider:PreloadAsync() to properly load all of it’s assets within the game

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

I will try all of these and get back to you.

I thought this would work and STILL the issue occurs

Complicated loops are more than you should need. Someone had this issue months ago and the simple solution I gave to them was that you should wait for the player’s character to load before running camera scripts. This gives ample time for camera modules to load, but is fast enough that the player isn’t waiting around for your camera scripts to work. I will try to find my responses to the other person and I will link them here.

1 Like

Here’s the other thread:

The solution script I posted here was inefficient because I just didn’t know about an easier way to do it. Here’s how I’d do it very simply:

local character = player.Character or player.CharacterAdded:Wait()
1 Like

I will try this and get back to you.

it can STILL break despite this. I will try using characterappearanceloaded instead and get back to you

for some reason characterappearanceloaded wont work so idk what to do.

Just for the sake of it, have you tried adding a wait(1) before setting the Camera?

If PreloadAsync() didn’t literally somehow manage to work either, maybe you can try this if you haven’t already?

-- LocalScript inside StarterPlayerScripts
local Cam = workspace.CurrentCamera
local focus -- Set your focus part here

local ContentProvider = game:GetService("ContentProvider")

local AssetsToLoad = {
    Cam,
    focus,
    -- Other assets to load which may work better since it yields longer --
}

ContentProvider:PreloadAsync(AssetsToLoad)

Cam.CameraType = Enum.CameraType.Scriptable
Cam.CFrame = focus.CFrame
1 Like

I will try this when I can and I will get back to you.

This happens to me all the time. But what I did to fix it was to put the LocalScript inside of StarterPlayerScripts instead of StarterGui.

1 Like

still no luck :frowning:
this is annoying

I have not tried this yet though so I will try this.

LOL STILL HAPPENING

I even tried putting it in multiple scripts and STILL nothing.

Maybe the character is loaded after the loop ends and this resets the camera type to custom or other, my only solution is to keep changing the camera type to your specified type over and over, although this is not efficient but it’s still made in the client + It’s just for the main menu, it shouldn’t be that bad since that’s currently the ultimate solution.

You can use :WaitForChild() so it will find the CameraPart evntually