UI Loading Screen Won't Appear

I’m working on a super simple loading screen that appears when a player joins. For some reason, the UI doesn’t appear at all - I have been working on fixing this for a good 5-6 hours now and have consulted some really talented lua developers who haven’t been able to figure this out, though I feel like the solution should be really simple.

I have pasted my code and a picture of the setup in Explorer below. As I said, the UI doesn’t appear at all - I added several print commands in different parts of the code as part of my debugging efforts and none of them came through, meaning that literally nothing is happening when this script runs.

Code
local loadScreen = script.Parent
local open = script.Parent.isOpen
local text = script.Parent.infoLabel
local info = script.Parent.TextLabel
local welcome = script.Parent.Parent.welcomeFrame
local open2 = script.Parent.Parent.welcomeFrame.isOpen
local Players = game:GetService("Players");

function onCharacterAdded()
    loadScreen.Visible = true
    open.Value = true
    wait(2)
    text.Text = [[If you like this game, please consider improving the ratings!]]
    wait(3)
    text.Text = [[You can instantly teleport back to the spawn in the Settings tab!]]
    wait(3)
    text.Text = [[Gamepass purchases fund more badges and my other games!]]
    wait(2)
    text.Text = [[Loading finished - enjoy the game!]]
    loadScreen.Visible = false
    open.Value = false
    welcome.Visible = true
    open2.Value = true
end

Players.LocalPlayer.CharacterAdded:Connect(onCharacterAdded)

Screenshot (533)

I’ve tried just about everything I’ve been told. I’ve added prints to debug, I’ve tried this script in StarterPlayerScripts, Workspace, StarterCharacterScripts, etc. I’ve even tried stupid things like using a Script instead of a LocalScript, changing certain parts of the code that should be working, adding an unnecessary amount of variables, etc.

I feel like this should be a really simple fix but I haven’t found anybody who can figure it out, so I decided to come here.

Try removing the ; after the (“Players”). Also, when you added the print statements, did it print anything out? And are there any errors? just reread the first paragraph, and found out they didn’t run.

Your sample script does not define loadscreen.

You have the variables open, text, info, welcome, open2, and Players, but your onCharacterAdded is calling a new variable loadscreen.

there are no errors with this code. every other UI in my game works perfectly.

That was just a mistake in copying and pasting - it is defined in the actual code. I will update the post accordingly

EDIT: updated :upside_down_face:

is StarterGui.ShowDevelopmentGui enabled? That can disable GUI in Studio and the setting can carry over to play testing.

Edit: However, if you add prints they should still show in the output window, so I’m not entirely sure that’s the case.

LocalScripts aren’t guaranteed to execute before CharacterAdded fires. You can just call the function directly below without connecting it to an event, not necessary to do that from a LocalScript unless it’s a non-resetting Gui that you’re controlling visibility for (which is also unnecessary because that behaviour can be natively achieved).

@LoveTheBears101 The semicolon has nothing to do with the script. It’s common for a lot of languages to require semicolons after every line of code: for Lua, it’s optional.

yes, it is enabled

Oh, I was just confused because that was the only line that had a semicolon.

ShowDevelopmentGui does not carry over into play solo sessions nor live games. That is strictly used for determining whether Guis should be visible while in Studio mode or not. This toggle is also native via the UI Editor (click “UI” in the topbar).

1 Like

unfortunately, i’m nowhere near as smart as you. what exactly are you suggesting here?

I’m suggesting literally to change from a connection to a direct call.

-- Old:
Players.LocalPlayer.CharacterAdded:Connect(onCharacterAdded)

-- New:
onCharacterAdded()

This is not on topic. Please do not hijack threads for personal affairs.

2 Likes

updated accordingly, however, the UI still doesn’t appear. Is it worthwhile to add prints again to see if anything is different?

You could try adding multiple breakpoints through out the code and check if there are any nil variables or variables that haven’t been assigned any value.

I also recommend adding this to ReplicatedFirst and calling the function ReplicatedFirst:RemoveDefaultLoadingScreen() after you’ve loaded the GUI. (Once the problem has been solved)*

Sometimes, CharacterAdded isn’t fired because the players character may spawn before the script is executed.

What I would recommend is putting this in replicated first, as anything in there will be loaded before anything else. Clone the screen GUI into the playerGUI , then execute the rest of the code.

This probably won’t work, but what happens if you run it, wait a few seconds, then reset your character? The OnCharacterAdded may not be running because your character loads before the script runs, so if you reset, the event should (theoretically) run.

Edit: whoops I just said basically what @Unknownstaffmembe said:

If resetting the character makes it show up, maybe try calling the function at the bottom of the script so it initially runs, then connects the function to the event.

1 Like

My apologies, I forgot about this thread.

@Unknownstaffmembe helped me partially fix it and I figured out the rest of the bugs on my own. Thanks for all the help guys!