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

Why does this only work in Play Solo?

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)

2 comments

2

What is line 6 used for, and why is the identifier 'property' necessary? I do not any of those two used anywhere in the code, also, have you considered using the 'WaitForChild' method? [Parent:WaitForChild(Child)]

0

Actually, I have no idea what that is for lol. I got this script from somebody else and edited it, idk what it is for lol

2 answers

✓ Accepted answer

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!

1 comment

0

Good explanation :) +1

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)

1 comment

0

no you dont, theres a simpler way. You always try to use LocalScripts in StarterGui or StarterPack

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