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

How can I remove a StarterGUI for a certain team?

Asked by 9 years ago

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

0
Can you please post some codes? UserOnly20Characters 890 — 9y
0
Be sure to accept Red's answer, to prevent other scripters from coming here Shawnyg 4330 — 9y

1 answer

Log in to vote
1
Answered by
Redbullusa 1580 Moderation Voter
9 years ago

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
1
`ClearAllChildren` would save you some characters on snippet#2 ImageLabel 1541 — 9y
0
Awesome! Thanks for helping me out. MountySyrus 5 — 9y
Ad

Answer this question