Can you please explain a thing about GUI's?

So last time I’ve tried explained an issue I have sometimes with GUI, but nobody understood, so…
If I write something like that:

local o = game:GetService("StarterGui"):WaitForChild("ScreenGui").Frame
wait(5)
o.Visible = false

--or

game:GetService("StarterGui"):WaitForChild("ScreenGui").Frame
wait(5)
o.Visible = false

then, well, nothing happens, and happens at the same time. In the properties the value is set, but it doesn’t change anything to the GUI itself. So I have to write

wait(5)
script.Parent.ScreenGui.Visible = false

and this is breaking everything if something isn’t loading correctly, and it’s simply harder to re-write the entire name of the GUI, which property I want to change.
The script only works if I put it into the StarterGui, which could be understandable, but this is not.
It works only if I write script.Parent…
Is it intentional? If it is, then what is the reason? Or it’s a bug only I am having? This makes everything really harder.

2 Likes

You should do this with a LocalScript.

Changing UI via the StarterGui wont work.
When a player enters a game, everything inside the StarterGui will be replicated to their PlayerGui, only a LocalScript can change this, they too get replicated inside PlayerGui.

1 Like

Gui’s are cloned to PlayerGui so you need to do game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled = false
Edit: You are saying .visible but it is .enabled

1 Like

Heres a little explanation as to why only script.Parent, the StarterGui serves no purpose other than cloning it’s contents into Player.PlayerGui. So changing the contents of a Gui in the StarterGui will do nothing, you have to change the already cloned ScreenGui directly. And its also good practice to make sure that things only visible to the client only should be manipulated with a LocalScript.

Basically, changing the gui via StarterGui is changing the template, not the actual gui itself

1 Like