{"id":157401,"date":"2024-09-17T13:29:52","date_gmt":"2024-09-17T11:29:52","guid":{"rendered":"https:\/\/hifivem.com\/?p=157401"},"modified":"2026-08-16T15:16:26","modified_gmt":"2026-08-16T13:16:26","slug":"how-to-create-a-loading-screen","status":"publish","type":"post","link":"https:\/\/fivemx.com\/pl\/how-to-create-a-loading-screen\/","title":{"rendered":"How to Create a FiveM Loading Screen"},"content":{"rendered":"<p><!-- fivemx-editorial-reindex:2026-08-16:157401 --><\/p>\n<p><strong>A current FiveM loading screen is an NUI resource declared with <code data-no-translation=\"\">loadscreen<\/code> in <code data-no-translation=\"\">fxmanifest.lua<\/code>.<\/strong> Keep the first version local and small: one HTML document, one stylesheet and one script. Add progress or server handover data only after the basic screen opens and closes correctly.<\/p>\n<div class=\"fivemx-guide-box fivemx-guide-warning\">\n<p><strong>Back up the existing resource and keep the default automatic shutdown first.<\/strong> A broken manual-shutdown script can leave players looking at the loading screen after the game is ready.<\/p>\n<\/div>\n<h2>Resource structure<\/h2>\n<pre data-no-translation=\"\"><code data-no-translation=\"\">resources\/[local]\/my_loadscreen\/\n\u251c\u2500\u2500 fxmanifest.lua\n\u2514\u2500\u2500 html\/\n    \u251c\u2500\u2500 index.html\n    \u251c\u2500\u2500 style.css\n    \u2514\u2500\u2500 app.js\n<\/code><\/pre>\n<p><code data-no-translation=\"\">fxmanifest.lua<\/code>:<\/p>\n<pre data-no-translation=\"\"><code data-no-translation=\"\" class=\"language-lua\">fx_version 'cerulean'\ngame 'gta5'\n\nauthor 'Your name'\ndescription 'FiveM loading screen'\nversion '1.0.0'\n\nloadscreen 'html\/index.html'\n\nfiles {\n    'html\/index.html',\n    'html\/style.css',\n    'html\/app.js'\n}\n<\/code><\/pre>\n<p>New resources should use <code data-no-translation=\"\">fxmanifest.lua<\/code>. Do not add a legacy <code data-no-translation=\"\">__resource.lua<\/code> fallback. The directives are defined in the official <a href=\"https:\/\/docs.fivem.net\/docs\/scripting-reference\/resource-manifest\/\" rel=\"nofollow noopener\" target=\"_blank\">resource manifest reference<\/a>.<\/p>\n<h2>Create accessible HTML<\/h2>\n<p><code data-no-translation=\"\">html\/index.html<\/code>:<\/p>\n<pre data-no-translation=\"\"><code data-no-translation=\"\" class=\"language-html\">&lt;!doctype html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n  &lt;meta charset=\"utf-8\"&gt;\n  &lt;meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"&gt;\n  &lt;title&gt;Connecting to Example RP&lt;\/title&gt;\n  &lt;link rel=\"stylesheet\" href=\"style.css\"&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n  &lt;main&gt;\n    &lt;h1&gt;Connecting to Example RP&lt;\/h1&gt;\n    &lt;progress id=\"progress\" value=\"0\" max=\"1\" aria-label=\"Loading progress\"&gt;&lt;\/progress&gt;\n    &lt;p id=\"status\" aria-live=\"polite\"&gt;Loading server resources\u2026&lt;\/p&gt;\n  &lt;\/main&gt;\n  &lt;script src=\"app.js\"&gt;&lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/code><\/pre>\n<p>Use text that remains readable over the background, respects reduced motion and does not depend on autoplay audio. Compress images and video before packaging them; every client has to download the resource.<\/p>\n<h2>Read the documented loading progress event<\/h2>\n<p><code data-no-translation=\"\">html\/app.js<\/code>:<\/p>\n<pre data-no-translation=\"\"><code data-no-translation=\"\" class=\"language-javascript\">const progress = document.getElementById('progress');\nconst status = document.getElementById('status');\n\nwindow.addEventListener('message', (event) =&gt; {\n  if (event.data?.eventName !== 'loadProgress') return;\n\n  const value = Number(event.data.loadFraction);\n  if (!Number.isFinite(value)) return;\n\n  const clamped = Math.max(0, Math.min(1, value));\n  progress.value = clamped;\n  status.textContent = `Loading ${Math.round(clamped * 100)}%`;\n});\n<\/code><\/pre>\n<p>The official <a href=\"https:\/\/docs.fivem.net\/docs\/scripting-manual\/nui-development\/loading-screens\/\" rel=\"nofollow noopener\" target=\"_blank\">Cfx.re loading-screen guide<\/a> documents <code data-no-translation=\"\">loadProgress<\/code> and the other events exposed to this NUI frame. Treat event data as input and update text with <code data-no-translation=\"\">textContent<\/code>, not <code data-no-translation=\"\">innerHTML<\/code>.<\/p>\n<h2>Pass only safe handover data<\/h2>\n<p>A server-side <code data-no-translation=\"\">playerConnecting<\/code> handler can pass small values with <code data-no-translation=\"\">deferrals.handover<\/code>. FiveM exposes them as <code data-no-translation=\"\">window.nuiHandoverData<\/code>. Use this for display values such as a player name; never include secrets, tokens, private identifiers or data that grants an entitlement. Insert player-controlled values with <code data-no-translation=\"\">textContent<\/code> or <code data-no-translation=\"\">innerText<\/code>.<\/p>\n<h2>Enable manual shutdown only when required<\/h2>\n<p>If the screen must fade out after client scripts start, add these lines:<\/p>\n<pre data-no-translation=\"\"><code data-no-translation=\"\" class=\"language-lua\">loadscreen_manual_shutdown 'yes'\nclient_script 'client.lua'\n<\/code><\/pre>\n<p>Then close it from <code data-no-translation=\"\">client.lua<\/code> after the actual client-ready condition:<\/p>\n<pre data-no-translation=\"\"><code data-no-translation=\"\" class=\"language-lua\">CreateThread(function()\n    while not NetworkIsSessionStarted() do\n        Wait(100)\n    end\n\n    ShutdownLoadingScreenNui()\nend)\n<\/code><\/pre>\n<p>Test reconnects, resource restarts and a slow client. If the screen can remain stuck, remove <code data-no-translation=\"\">loadscreen_manual_shutdown<\/code> and the client script to return to automatic lifecycle handling.<\/p>\n<h2>Deploy and verify<\/h2>\n<ol>\n<li>Add <code data-no-translation=\"\">ensure my_loadscreen<\/code> to the intended point in <code data-no-translation=\"\">server.cfg<\/code>.<\/li>\n<li>Use <code data-no-translation=\"\">refresh<\/code> and <code data-no-translation=\"\">ensure my_loadscreen<\/code> on a development server.<\/li>\n<li>Connect with a clean client and inspect F8 plus the server console.<\/li>\n<li>Test a slow connection, reconnect, cancelled connection and server restart.<\/li>\n<li>Check common desktop resolutions and a low-powered client before replacing the production resource.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Build a current FiveM loading-screen resource with fxmanifest.lua, local HTML assets, progress events, safe handover data and an optional controlled shutdown.<\/p>","protected":false},"author":1,"featured_media":36325,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2340,3207,1899],"tags":[3001,2869],"class_list":["post-157401","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-lua-scripting","category-loading-screens","category-tutorials","tag-fivem-script","tag-loading"],"_links":{"self":[{"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/posts\/157401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/comments?post=157401"}],"version-history":[{"count":2,"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/posts\/157401\/revisions"}],"predecessor-version":[{"id":217361,"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/posts\/157401\/revisions\/217361"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/media\/36325"}],"wp:attachment":[{"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/media?parent=157401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/categories?post=157401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemx.com\/pl\/wp-json\/wp\/v2\/tags?post=157401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}