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

How can I remove a StarterGUI for a certain team?

Hi fellow scripters! After trying to fix this issue for days, I could only come up with removing the BUTTONS, but not the whole GUI.. Could any of you guys help me out? :D

2 comments

0

Can you please post some codes?

0

Be sure to accept Red's answer, to prevent other scripters from coming here

1 answer

✓ Accepted answer

You can't remove StarterGui, as that's the instance that replicates the GUIs to the player instances, thus removing it is irrelevant to your situation.

What you can do, though, is removing the ScreenGUI object itself.

-- If this script is a system script that manages every player in the game
for i, v in pairs (game.Players:GetPlayers()) do -- Get the players
    if v.TeamColor == "Bright blue" and v:WaitForChild("PlayerGui"):FindFirstChild("YourGuiHere") then
-- If the player is in Bright blue team and has the GUI itself 
        v.PlayerGui.YourGuiHere:Destroy()
    end
end

If you meant to remove all of the GUIs of the players of a certain team...

for i, v in pairs (game.Players:GetPlayers()) do
    if v.TeamColor == "Bright blue" then
-- If the player is in the Bright blue team
        for i, obj in pairs (v:WaitForChild("PlayerGui"):GetChildren()) do
-- Gets everything in the PlayerGui
            if obj:IsA("ScreenGui") then -- Just in case
                obj:Destroy()
            end
        end
    end
end
-- Simple iteration of the players and the PlayerGuis

2 comments

1

ClearAllChildren would save you some characters on snippet#2

0

Awesome! Thanks for helping me out.

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