First, create a ScreenGui object in the StarterGui service. This will serve as the container for your loading screen UI elements.
Second, Add a Frame UI element as a child of the ScreenGui. This Frame will serve as the background for your loading screen.
Third, Inside the Frame, you can add a TextLabel to display loading messages or an ImageLabel to display a loading animation.
local loadingScreenGui = Instance.new("ScreenGui")
loadingScreenGui.Name = "LoadingScreen"
loadingScreenGui.Parent = game:GetService("StarterGui")
local backgroundFrame = Instance.new("Frame")
backgroundFrame.Size = UDim2.new(1, 0, 1, 0) -- Fill the entire screen
backgroundFrame.BackgroundColor3 = Color3.new(0, 0, 0) -- Black background
backgroundFrame.BackgroundTransparency = 0.5 -- Semi-transparent
backgroundFrame.Parent = loadingScreenGui
local loadingTextLabel = Instance.new("TextLabel")
loadingTextLabel.Size = UDim2.new(0, 200, 0, 50)
loadingTextLabel.Position = UDim2.new(0.5, -100, 0.5, -25) -- Centered
loadingTextLabel.AnchorPoint = Vector2.new(0.5, 0.5)
loadingTextLabel.Text = "Loading..."
loadingTextLabel.TextColor3 = Color3.new(1, 1, 1) -- White text
loadingTextLabel.TextScaled = true
loadingTextLabel.Parent = backgroundFrame
wait(3) -- Simulate loading for 3 seconds
loadingScreenGui:Destroy()