Scripting a loading screen, some things arent working

So basically im writing code for a loading screen. Here is what the current loading screen looks like as of now

So basically whats supposed to be happening, is that those diagnol stripe pattern is supposed to be looped repeatedly moving towards the left (like a loading bar kinda), the text that says “Assets Rendered” is supposed to count how many out of the total assets have been loaded. But its not working for some odd reason

Heress my script

local repStorage = game:GetService("ReplicatedStorage")
local repFirst = game:GetService("ReplicatedFirst")
local contProv = game:GetService("ContentProvider")
local loadingArea = script.loadingArea

local assets = game:GetDescendants()

local UI1 = script.loadingArea:Clone()

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")

repeat wait() until game:IsLoaded()

UI1.Parent = PlayerGui

for i = 1, #assets do
	local asset = assets[i]
	
	contProv:PreloadAsync({asset})
	while true do
		UI1.loadingBackground.loadingSubtitle.Text = "Downloading Assets"
		wait(1)
		UI1.loadingBackground.loadingSubtitle.Text = "Downloading Assets."
		wait(1)
		UI1.loadingBackground.loadingSubtitle.Text = "Downloading Assets.."
		wait(1)
		UI1.loadingBackground.loadingSubtitle.Text = "Downloading Assets..."
		wait(1)
	end
	
	UI1.loadingBackground.loadingSubtitle.Text = "Putting peices together"
	UI1.loadingBackground.assetsrendered.Text = "Assets Rendered: "..asset.Name.." ["..i.."of"..#assets.."]"
end
wait(1)
UI1.loadingBackground.loadingSubtitle.Text = "Finished1"
wait(1)
UI1:Destroy()

print("Loading complete")

Can anybody tell me whats going on and what needs to be added, removed so i can fix this to get it to work? Scripting isnt my special power so yeah. Thanks if anyone would like me to elaborate more on this please feel free to let me know

2 Likes

You have an infinite loop in while true do. Nothing after it will be executed.

3 Likes

So basically i put my code before said loop?

You could remove the loop entirely or place it in a coroutine | Documentation - Roblox Creator Hub that runs until loading has finished. No matter where you place the loop it will never exit because the condition will always be true.

1 Like

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