I have a city game but there is a team change GUI and when on the prisoner team the prisoners can team themselves back to civilians when arrested with the GUI so how would I make it so when on that team it removes the GUI?
COMMUNITY QUESTION
How can I destroy a GUI on a certain team?
1 answer
Supposing that each player of this team has the Gui in their PlayerGui, all you'll have to do is get these players PlayerGuis, by getting all players and filtering those in the team. Something like this:
for i, player in pairs(game.Players:GetPlayers()) do
if player.Team == team then
player.PlayerGui.Gui:Destroy()
end
end
I assumed Gui as the Gui you want to delete and team as the actual Team object, located in game.Teams. You can use the TeamColor property too, so you don't have to use the actual object.
Also, you could just hide the Gui, so you don't have to delete it.
This discussion is preserved as it was. New answers, comments, and votes are closed.
