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

Script won't work?

This is supposed to work, (obviously), but it won't. If you could, please tell me how to FIX IT, and not ''well this is wrong''. Everything is in the correct place, period. If someone could, please take the five seconds it would take to fix it, or tell me what I did wrong and THEN EXPLAIN HOW I CAN FIX IT. ''it's wrong'' doesn't say anything.

The brick goes invisible, and so is the GUI (well, it's supposed to, anyways)

game.PlayerGui.GUI1.TextLabel.Visible = false --This turns GUI1 off wait(4) --this makes it wait for the next thing game.PlayerGui.GUI2.TextLabel.Visible = true --GUI2 IS DIFFERENT, SO I KNOW IF IT WORKS OR NOT

.

2 comments

0

P.S nobody ever ''tested this in studio'' the guy who said so is a liar.

0

... Wow. I tested it in Studio. It works. You didn't comply with my questions. I set up my script with your scenario and went in there and made the brick invisible, and it worked. I asked you a few questions to see if your scenario is different, but instead of answering them so that I can help you out, you delete my answer, you delete my comment, and you call me a liar. Don't expect me to answer a

1 answer

In the future, please place your code in a code block. You can do so by placing your code in between the lines created after clicking the little blue Lua symbol. Since your code is short, however, I can do it;

game.PlayerGui.GUI1.TextLabel.Visible = false --This turns GUI1 off 
wait(4) --this makes it wait for the next thing 
game.PlayerGui.GUI2.TextLabel.Visible = true --GUI2 IS DIFFERENT, SO I KNOW IF IT WORKS OR NOT

Your problem is that the PlayerGui service you attempt to use does not exist.

There is a StarterGui game service that is a "holder" for all GUIs. The GUIs in StarterGui will eventually be cloned into PlayerGui (which is a child of all Players) each time their Character respawns.

StarterGui is not what a Player is currently seeing; they are seeing whatever is in their PlayerGui. Changes made to the PlayerGui are not saved, however, for all GUIs will be "re-cloned" from StarterGui next time the Character respawns.

The hierarchy looks like this;

Game
	Players
		Player
			PlayerGui
				Gui
	StarterGui
		Gui

Although I don't know exactly what you want to happen, since you did not specify in your question, your best bet is probably to use a LocalScript inside a ScreenGui, with both GUIs places inside of a single ScreenGui. You may then access them easily.

Hierarchy:

StarterGui
	ScreenGui
		LocalScript
		GUI1
		GUI2

You can then get the GUIs from simply, script.Parent.GUI1.

script.Parent.GUI1.Visible = false
wait(4)
script.Parent.GUI2.Visible = true

Just remember that this code will run as soon as it is cloned into PlayerGui, so you may not be able to see the GUIs change perfectly due to a laggy camera.

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