Loading Screen Local Script Review

This code does work, but I feel like it could definitely be improved. This is for a loading screen that will show the assets being loaded in, and then once completed, it will fade out and show a menu screen. Any tips?

local ContentProvider = game:GetService("ContentProvider")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local StarterGui = game:GetService("StarterGui")
local success

local text = script.Parent

local loadInstances = workspace:GetDescendants()
local cameraAngles = workspace:FindFirstChild("CameraAngles")

local player = game:GetService("Players").LocalPlayer
local respawnEvent = game:GetService("ReplicatedStorage").RespawnEvent

local mainMenu = script.Parent.Parent.MainMenu
mainMenu.Visible = false

script.Parent.Visible = true

respawnEvent:FireServer(workspace:FindFirstChild("LoadingPart"),false)

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

repeat
	RunService.Heartbeat:Wait()
	success = pcall(StarterGui.SetCore,StarterGui,"ResetButtonCallback",false)
until success

for i=1,#loadInstances do
	local loading = loadInstances[i]
	ContentProvider:PreloadAsync({loading})
	
	text.Text = tostring(math.floor((i/#loadInstances)*100)).."%\n"..tostring(i).."/"..tostring(#loadInstances)
end

local randomAngle = cameraAngles:GetChildren()[math.random(1,#cameraAngles:GetChildren())]
local currentCam = workspace.CurrentCamera
currentCam.CameraType = Enum.CameraType.Scriptable
local fov = randomAngle:GetAttribute("FOV")
if fov then currentCam.FieldOfView = fov end
currentCam.CFrame = randomAngle.CFrame

task.wait(1)

mainMenu.Visible = true
local tweenOut = TweenService:Create(text,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out),{BackgroundTransparency = 1,TextTransparency = 1})
tweenOut:Play()