This LocalScript is supposed to wait until Loading is visible, open a Gui, then wait 10 seconds. If it is still visible (This is important!) Then it needs to make in invisible, and make results visible. It works perfectly in PlaySolo, but in-game doesn't work. Help please!!!
Here's the LocalScript
player = game.Players.LocalPlayer gui = player.PlayerGui.ScreenGui loading = script.Parent results = gui.results loading.Changed:connect(function(property) local value = property loading.worked.Visible = true wait(5) if loading.Visible == true then wait(1) loading.Visible = false results.Visible = true wait() end end)
This problem is very common, but it comes with an easy fix.
Since this is a local script, it only runs in the client, unlike a server-sided script. This makes the script run a whole lot faster. More often than not, it will start sooner than when the Player and their GUIs load.
As TheAlphaStigma mentioned in the comment, you may use a WaitForChild()
method to wait until the intended object is 'loaded.'
gui = player.PlayerGui:WaitForChild("ScreenGui")
You may do this for the rest of your variables that are used in your script.
results = gui:WaitForChild("results")
If that still doesn't work, then I would suggest to have the script to pause its thread until the Player itself is completely rendered using a 'repeat... until [condition]'.
repeat wait() until game.Players.LocalPlayer player = game.Players.LocalPlayer
I hope this helps!
This happens a lot, basically because you HAVE to use a normal script instead of a basic one.
player = PUT PLAYER'S LOCATION HERE gui = player.PlayerGui.ScreenGui loading = script.Parent results = gui.results loading.Changed:connect(function(property) local value = property loading.worked.Visible = true wait(5) if loading.Visible == true then wait(1) loading.Visible = false results.Visible = true wait() end end)