Hiding a Textbutton in a GUI on a Certain Team

Very amateur scripter as this isn’t my department of expertise. How would I go about hiding a TextButton so that a player, let’s say on a prisoners team, cannot press the team change button?

image

The TextButton (teams) highlighted in the above image is what I’m aiming to disable until the player is automatically changed teams after serving their stint in prison. I’ve looked for solutions but thus far they haven’t been successful in disabling just this textbutton.

You can check using the Player.Team property and verify the player’s team using that. For your use case, you could either check periodically with a while loop or you could use Player.AttributeChanged or Player.Changed (can’t remember which event can be used for this).

1 Like

.Changed is for property changes, .AttributeChanged is for when an attribute of that instance is changed Attributes aren’t out yet FYI!

Alternatively, you can use :GetPropertyChangedSignal("Team") as that’ll provide a RBXScriptSignal for when only their Team changes.

You can read more here:

Worth noting for the OP and anyone else who may adopt this kind of a concept into their game: remember, your server also needs to play a part in this by not processing any team changes by the client if they’re on said prisoners team. Hiding the Team Change Gui is fine as far as a vanilla, untampered game experience goes, but make sure also to secure your server-side against bad actors.