How do I make my loading screen useful

How do I make my loading screen useful

Lots of my scripts run before the loading screen script can finish loading all assets. I feel this can be dangerous in the sense that some scripts can break if they can’t find parts in the game. This is because im assuming that all parts have already loaded in using my loading screen script.

All I want is for any script in my game to run safely and me not having to have to rely on “waitforchild” and stuff like that. I honestly don’t know if it’s already working well or if I need my scripts to run after my loading screen script loaded all assets?

Here is my loading screen script (very simple):

-- Services
local players = game:GetService("Players")
local RF = game:GetService("ReplicatedFirst")
local RP = game:GetService("ReplicatedStorage")
local CP = game:GetService("ContentProvider")

RF:RemoveDefaultLoadingScreen() -- Removes default loading screen

-- Constants
local GOAL_COLOR = Color3.new(1, 1, 1)

-- Variables
local player = players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

--local modules = RP:WaitForChild("Modules")
--local phraseModule = require(modules:WaitForChild("PhrasesModule"))

local loadingScreen = script:WaitForChild("LoadingScreen"):Clone()
loadingScreen.Parent = playerGui

local loadingScreenGuis = loadingScreen:WaitForChild("LoadingScreenGuis")
local Bar = loadingScreenGuis:WaitForChild("LoadingBar"):WaitForChild("Bar")
local percentageText = loadingScreenGuis:WaitForChild("PercentageText")

local assets = game:GetChildren()
--local currentPhrase = phraseModule[math.random(1,#phraseModule)]

for index,asset in assets do -- Loads assets
	CP:PreloadAsync({asset})
	
	local progress = index / #assets
	Bar.Size = UDim2.fromScale(progress,1)
	Bar.BackgroundColor3 = Bar.BackgroundColor3:Lerp(GOAL_COLOR,progress)
	percentageText.Text = tostring(math.floor(progress * 100)) .. "%"
end

print("loaded")

Don’t worry about the parts I commented out.