Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How to make a TextButton in StarterGui Invisible?

Asked by 5 years ago

For some reason, I can't find out a way to make a working line of code to just make the Visible property of a TextButton Gui to be false, from a non-Local script in workspace. I tried doing something like this:

local sgui = game:GetService("StarterGui")

sgui.ScreenGui.Button1.Visible = false

But that didn't work. Then, I thought I had to call the PlayerGui instead. Since this will activate when the player touches a brick, I tried something like:

  local you = game.Players:FindFirstChild(hit.Parent.Name)
  local btn = you.PlayerGui.ScreenGui.MSonicFormsBtn
  if not btn.Visible == true then btn.Visible = true end

But that also didn't work. I feel like, since it's just changing a property of something that's simply located in StarterGui, it's something easy that I'm forgetting. But I can't figure it out for the life of me.

0
PlayerGui not screen gui greatneil80 2647 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

GUI instance's are client only interface objects, and as such they should only be mutated by client (local) scripts, even for the odd-ball cases that automatically replicate. You should use a remote event to tell the client to update it's gui if the change is determined in a server script.

StarterGui is used to house template screengui instances that are cloned and placed into each client's PlayerGui at either load time, or for every respawn, determined by a 'ResetOnSpawn' property.

Because a clone of the ScreenGui is given to the client's PlayerGui, making changes to the ScreenGui will not display for any players. You need to mutate the clone of the ScreenGui that exists in Player.PlayerGui if you want changes to display without requiring a respawn.

0
Out of curiosity what "odd-ball" UI instances automatically replicate. What exactly does that mean? SummerEquinox 643 — 5y
0
I think he means the PlayerGui folder maybe? User#19524 175 — 5y
Ad

Answer this question