Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make other LocalScripts wait for one script to be done?

Right now I have a loading screen Gui that takes 4 seconds to complete. I have a Menu Gui that waits 4 seconds to pop up. But this Gui has "ResetOnSpawn" Enabled so it waits 4 seconds every time I respawn. How can I check to see if the loading Screen Gui is enabled and make it wait 4 seconds if it is enabled? I tried this code but it doesn't work, no output errors. Idk if you guys need any more of my code.

if game.StarterGui.LoadingGui.Enabled == true then
	wait(4)
end

1 answer

✓ Accepted answer
if game.StarterGui.LoadingGui.Enabled == true then
    wait(4)
end

This code doesn't work because you're checking for the LoadingGui that is inside StarterGui, not the actual LoadingGui that is on the LocalPlayer's screen.

Here you can see that the GUIs on the player's screen is inside game.Players.LocalPlayer.PlayerGui: https://i.imgur.com/ddhOycO.png

So you should modify the actual LoadingGui inside PlayerGui by doing:

game.Players.LocalPlayer.PlayerGui.LoadingGui

One issue with this line of code is that LoadingGui may not have loaded in yet, so you have to use WaitForChild:

local loadingGui = game.Players.LocalPlayer.PlayerGui:WaitForChild("LoadingGui")

So your code should look like this:

local loadingGui = game.Players.LocalPlayer.PlayerGui:WaitForChild("LoadingGui")
if loadingGui.Enabled == true then
    wait(4)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.