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

How to remove all gui but not specific one?

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)

3 comments

0

I don't think "GetFirstChildren" is a thing??

0

Is that the only problem?

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)

1 answer

✓ Accepted answer

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)

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