Disabling ScreenGuis

Hello, so I’ve made a loading screen which works perfectly except for one small issue that the other screenguis I have in Starter/PlayerGui are all enabled. And I want all the others ones to be disabled until the loading screen is done loading and then enable all the others again.

Client script

local plr = game.Players.LocalPlayer
local gui = script.Parent
local background = gui:WaitForChild("Background")
local bar = background:WaitForChild("Bar")
local filler = bar:WaitForChild("Filler")
local percentage = bar:WaitForChild("Percent")
local events = game.ReplicatedStorage:WaitForChild("Events")
local playerGui = plr.PlayerGui

local tweenService = game:GetService("TweenService")

wait(2)

local screenGuis = playerGui:GetChildren()

for _, gui in pairs(screenGuis) do
	if gui:IsA("ScreenGui") then
		if gui.Name ~= "LoadingMenu" then
			gui.Enabled = false
		end
	end
end

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)

local function animate(i)
	percentage.Text = i.."%"

	local formula = i/100

	filler:TweenSize(UDim2.new(formula,0,1,0), "Out", "Linear", 0.04, true)


	if i == 24 then
		wait(1.1)
		bar.Info.Text = "Loading Core GUI..."

	elseif i == 44 then
		wait(.6)
		bar.Info.Text = "Loading terrain..."

	elseif i == 79 then
		wait(.5)
		bar.Info.Text = "Loading map..."	

	elseif i == 91 then
		wait(.8)
		bar.Info.Text = "Finalising..."

	end

	if i < 100 then
		wait(0.04)
		animate(i + 1)
	end
end

animate(0)

if plr:GetRankInGroupAsync(34363373) >= 200 then
	plr.Team = game.Teams.Headquarters
elseif plr:GetRankInGroupAsync(34363373) >= 8 then
	plr.Team = game.Teams.Officers

elseif plr:IsInGroupAsync(34364980) then
	plr.Team = game.Teams["15th Infantry Division"]



elseif not plr:IsInGroupAsync(34363373) then
	plr.Team = game.Teams.Civilians
end


events.SpawnPlayer:FireServer()
wait(1)
gui:Destroy()
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)

I tried this but it still loads all other screenGuis still.

Explorer
image

So the LoadingMenu GUI is moved into persons playergui after joining.

1 Like

Note: I don’t know what i did but it works now? Idk how but it works now.