How to Disable Multiple CoreGui's?

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList,false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.EmotesMenu,false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat,false)

This is Ugly,
And you might Say: "Just use Enum.CoreGuiType.All!"
But that’s not what I want, I want some CoreGuis to be Active while others Aren’t, I was wondering if it was possible to have an Array of Enum.CoreGuiTypes for the function to Apply instead of calling the function several times?

Doing it Normally would just say:
Unable to cast Array to token

Thanks.

local DisableGuiTypes = {
PlayerList = false;
EmotesMenu = false;
Chat = false
}

for type, enabled in ipairs(DisableGuiTypes) do
    game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType[type], enabled)
end

I have not tested this, but it should be what you are looking for.

2 Likes

Iterate over the array

for _, gui in enumArray do
    game.StarterGui:SetCoreGuiEnabled(gui, false)
end

Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.