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

What is the best way to use an if statement without using while true do?

Hello, i'm working on a loading screen and I keep running into some issues where the if Load < 1 then doesn't execute and nothing comes out in the output regarding this script, you may notice that I have a while true do loop for the TextLabel that states how many assets are remaining, but i cant use the same thing for the if Load < 1 then because this also duplicates a main menu onto the players screen, and it will duplicate it and keep going so i cant use a true do loop to fix it, if anyone could help me out it would be appreciated, here is my script:

local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local Load = game:GetService("ContentProvider").RequestQueueSize

script.Parent.Text = "Preparing Client"
wait(0.3)

while true do
wait(0)
local Load = game:GetService("ContentProvider").RequestQueueSize
script.Parent.Text = "Loading Assets ("..Load.." Assets Remaining)"
end

if Load < 1 then
	script.Parent.Text = "Loading Complete."
	wait(1)
	script.Parent.Parent:TweenPosition(UDim2.new(0, 0,-2, 0))
	PlayerGui:SetTopbarTransparency(0.5)
	game.ReplicatedFirst.LoadingGUI.LoadingMusic:Stop()
	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
	script.Parent.Parent.Parent.SkipLoadingConfirmation:TweenPosition(UDim2.new(0.75, 1,-2, 1))
	wait(0.1)
	local MainMenuGUI = game.Workspace.MainMenuComponents.MainMenu:Clone()
	MainMenuGUI.Parent = PlayerGui
end

1 answer

✓ Accepted answer

change

if Load < 1 then

to

if Load <= 1 then

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