I am trying to make a script that hides all the GUI when a certain GUI is visible (in this case, in PlayerGui) and it doesn’t seem to be working (No errors are occurring though)
Script:
local gui = script.Parent
local blur = game.Lighting.BlurBkg
local player = game.Players.LocalPlayer
game.Players.PlayerAdded:Connect(function()
if gui.Parent == "PlayerGui" and gui.Enabled == true then
local playerGUI = gui.Parent
for _, otherGUI in pairs(playerGUI:GetChildren()) do
if otherGUI:IsA("ScreenGui") and otherGUI.Name ~= gui.Name then
otherGUI.Enabled = false
end
end
blur.Enabled = true
elseif gui.Parent ~= "PlayerGui" then
local playerGUI = player.PlayerGui
blur.Enabled = false
for _, otherGUI in pairs(playerGUI:GetChildren()) do
if otherGUI:IsA("ScreenGui") and otherGUI.Name ~= gui.Name then
otherGUI.Enabled = true
end
end
end
end)