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

How to remove all gui but not specific one?

Asked by
130363 67
7 years ago

So basically what I'm trying to do is remove all the GUIs in the PlayerGui of the player but not the gui called Chat,HelpGui,Clean, and Flare.

local Players = game:GetService('Players');
script.Parent.MouseButton1Click:Connect(function()
game.Players.PlayerAdded:connect(function(plr)
    local playerGui = plr.PlayerGui

    wait(3)
    for i = 1, #playerGui do
        local child = playerGui[i];
        if child.ClassName == "ScreenGui" and not plr.PlayerGui:GetFirstChildren(Chat,HelpGui,Clean,Flare) then
            child:Destroy()
        end
    end
end)
0
I don't think "GetFirstChildren" is a thing?? LightModed 81 — 7y
0
Is that the only problem? 130363 67 — 7y
0
Just try having a backup copy in serverstorage or where you prefer keeping your stuff. Then just make it add it after a wait(1). You can just do SafeGUI.Parent = (where you want it) camxd01 48 — 7y

1 answer

Log in to vote
0
Answered by
Validark 1580 Snack Break Moderation Voter
7 years ago

Every time script.Parent is clicked, all ScreenGuis not called "Chat", "HelpGui", "Clean", or "Flare" are all removed

local Players = game:GetService('Players')
local LocalPlayer = Players.LocalPlayer
local Guis = LocalPlayer:WaitForChild("Guis")

script.Parent.MouseButton1Click:Connect(function()
    wait(3)
    local Guis = Guis:GetChildren()
    for i = 1, #Guis do
        local Child = Guis[i]
        if Child.ClassName == "ScreenGui" and not Child.Name == "Chat" and not Child.Name == "HelpGui" and not Child.Name == "Clean" and not Child.Name == "Flare" then
            Child:Destroy()
        end
    end
end)

Ad

Answer this question