Why not just enable the native cursor in the loading screen?
https://docs.fivem.net/docs/scripting-manual/nui-development/loading-screens/#cursorinput