Help on game:IsLoaded()

I have the following script:
(Of course, it’s pretty obvious what the variables are)

if Timer ~= 0 then
	wait(Timer)
	ReadyToFade = true
	wait(1)
	ScreenGui:Destroy()
else
	if not game:IsLoaded() then
		game.Loaded:Wait()
	end
	ReadyToFade = true
	wait(1)
	ScreenGui:Destroy()
end

However, the problem is that if the timer is 0, it should wait for the game to load and destroy the ScreenGui. But, it doesn’t. I did this in the CommandBar: print(game:IsLoaded()) and it printed true. Can anyone help me?

1 Like

Try doing the:

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

At the start of the script.

1 Like

You mean switch the statements? Becuase I can’t put that on top of everything.

Why not? It’s basically like doing

local Player = game.Players.LocalPlayer
repeat wait() until Player.Character

at the start of the script, isn’t it?

I would like to do that after some functions have been called. That showed script is not inside a loop, basically just the raw if statement.

You can put it on top of the if statement if you want. The placement doesn’t matter as long as anything beyond isn’t looking for / changing something that wouldn’t yet be loaded at that time.

Tried that, but it stopped the functions from working. I would like to put it at the bottom, but why isn’t it working?

The functions probably don’t work because of what I previously mentioned:

The placement doesn’t matter as long as anything beyond isn’t looking for / changing something that wouldn’t yet be loaded at that time.

Sadly the functions are in order and if I put the statement above the first function that it sees, it would still stop working.

local Player = game.Players.LocalPlayer
repeat wait() until Player.Character

Try this at the very start of the script if nothing works. It might end up being something else other than the IsLoaded.

This is basically the same but it makes sure the character is ready.

I don’t get what you’re saying. The Player itself is loaded 100%, and I will try that variant of script for the game.IsLoaded.

Edit: same result. I don’t know what’s going on anymore.

Where is this code located, I would advise you to put IsLoaded in Replicatedfirst as a local script.

2 Likes

Yeah, those stuff are COMPLETELY different. The location is inside a ServerScript, inside StarterGui. Let me try.

What do you mean by “those stuff.”

I meant

And

I’ll try now. Thanks.