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

How to make a TextButton in StarterGui Invisible?

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.

1 comment

0

PlayerGui not screen gui

1 answer

✓ Accepted answer

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.

2 comments

0

Out of curiosity what "odd-ball" UI instances automatically replicate. What exactly does that mean?

0

I think he means the PlayerGui folder maybe?

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