Controlling when your loading screen closes (loadscreen_manual_shutdown)

10 min read5 sections · 5 questions answered
Short answer

Add loadscreen_manual_shutdown 'yes' to the loading screen’s fxmanifest.lua. The screen then stays up after loading finishes until a client script calls ShutdownLoadingScreenNui(). Call it from the resource that knows the player is ready — usually the multicharacter or spawn script — and always have a fallback so a failed script cannot leave players stuck.

By default the loading screen disappears the instant the game has loaded — often a second or two before your character selector, spawn camera or framework is actually ready, which leaves players staring at a frozen, half-loaded world. Manual shutdown lets you keep the loading screen up until your scripts say so, and close it with a fade instead of a cut.

What happens by default

Without manual shutdown, FiveM closes the loading screen when the game finishes loading the session. Your framework may still be fetching the character list, the spawn selector may not have opened, and the player sees the raw game world for a moment — sometimes under the map, sometimes mid-air.

Enabling manual shutdown

fxmanifest.lua (the loading screen resource)
fx_version 'cerulean'
game 'gta5'

loadscreen 'index.html'
loadscreen_manual_shutdown 'yes'

files { 'index.html', 'style.css', 'script.js' }
client.lua (your spawn or multicharacter resource)
-- Call when the player can see something worth seeing
local function closeLoading()
    ShutdownLoadingScreen()     -- the game's own loading screen
    ShutdownLoadingScreenNui()  -- your HTML loading screen
end

The shutdown call can come from any client script, not only the loading screen’s own resource. That is the point: the resource that knows the player is ready decides.

Frameworks and multicharacter scripts

Most multicharacter and spawn-selector resources already call ShutdownLoadingScreenNui() when their UI opens. If you enable manual shutdown and use one of them, check that it does — search its client files for ShutdownLoadingScreenNui. If it does not, add the call where its interface becomes visible.

A safety fallback

client.lua — never leave players stuck
CreateThread(function()
    -- If nothing has closed the loading screen 45 s after the session started, close it.
    while not NetworkIsSessionStarted() do Wait(500) end
    Wait(45000)
    ShutdownLoadingScreen()
    ShutdownLoadingScreenNui()
end)

Calling the shutdown natives when the screen is already closed does nothing, so the fallback is harmless when everything works.

Fading out instead of cutting

Before closing, send the page a message so it can fade to black, then shut it down a moment later. On the game side, fade the screen in from black once the loading screen is gone for a clean transition.

client.lua
SendLoadingScreenMessage(json.encode({ action = 'fadeOut' }))
Wait(800)
ShutdownLoadingScreen()
ShutdownLoadingScreenNui()
DoScreenFadeIn(600)
script.js (loading screen)
window.addEventListener('message', (e) => {
  if (e.data && e.data.action === 'fadeOut') {
    document.body.style.transition = 'opacity .7s ease';
    document.body.style.opacity = '0';
    const audio = document.querySelector('audio');
    if (audio) fadeVolume(audio, 700);
  }
});

function fadeVolume(audio, ms) {
  const start = audio.volume;
  const t0 = performance.now();
  (function step(now) {
    const k = Math.min(1, (now - t0) / ms);
    audio.volume = start * (1 - k);
    if (k < 1) requestAnimationFrame(step);
  })(t0);
}

Common questions

What does loadscreen_manual_shutdown do?

It keeps the loading screen visible after the game has loaded, until a client script calls ShutdownLoadingScreenNui().

Where do I put loadscreen_manual_shutdown?

In the fxmanifest.lua of the loading screen resource, next to the loadscreen line.

Which script should close the loading screen?

The one that knows the player is ready — usually your multicharacter or spawn-selector resource. It calls ShutdownLoadingScreenNui().

Why are my players stuck on the loading screen after enabling manual shutdown?

Nothing calls ShutdownLoadingScreenNui(). Add the call where your spawn UI opens, plus a safety timeout.

What is the difference between ShutdownLoadingScreen and ShutdownLoadingScreenNui?

ShutdownLoadingScreen closes the game’s own loading screen; ShutdownLoadingScreenNui closes your HTML loading screen. Spawn scripts usually call both.

Want a loading screen you never have to debug?

Build it in the browser, export once, and edit it whenever — no HTML, no re-uploads.

Start free

More guides