Loading/Intro Screen Won't Work

I was watching a tutorial on YouTube on how to create an intro loading screen for a game, however, mine just doesn’t seem to work. I followed all the steps and I have no idea what I’m doing wrong, I’ve been trying to pick at it for an hour now. Any advice or help? (not a scripter)

The code:

local ContentProvider = game:GetService("ContentProvider")
local holder = script.Parent.Holder
local assets = game:GetDescendants()

game.ReplicatedFirst:RemoveDefaultLoadingScreen()

local function start()
	for i=1, #assets do
		ContentProvider:PreloadAsync({assets[i]})
		
		local percentage = math.floor(i/#assets * 100).."%"
		
		holder.BarFrame.Assets.Text = "Assets Loaded: "..i.."/"..#assets
		holder.BarFrame.Percentage.Text = percentage.."%"
		
		holder.BarFrame.Bar:TweenSize(UDim2.fromScale(percentage/100, 1), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.1)
	end
	
	wait(1)
	
	holder:TweenPosition(UDim2.fromScale(0.5, -1.5), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1)
end
1 Like

doesnt look like you’re starting it

Hi there, what do you mean by that? Is there something I’m missing?

It seems like you’re not actually calling the start() function anywhere in your script.

To fix this, you should add a line of code at the end of your script to call the start() function.

local ContentProvider = game:GetService("ContentProvider")
local holder = script.Parent.Holder
local assets = game:GetDescendants()

game.ReplicatedFirst:RemoveDefaultLoadingScreen()

local function start()
	for i=1, #assets do
		ContentProvider:PreloadAsync({assets[i]})
		
		local percentage = math.floor(i/#assets * 100).."%"
		
		holder.BarFrame.Assets.Text = "Assets Loaded: "..i.."/"..#assets
		holder.BarFrame.Percentage.Text = percentage.."%"
		
		holder.BarFrame.Bar:TweenSize(UDim2.fromScale(percentage/100, 1), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.1)
	end
	
	wait(1)
	
	holder:TweenPosition(UDim2.fromScale(0.5, -1.5), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1)
end

start() -- Call the function above
1 Like

local function start()
    print("BOOO")
end

start() -- this starts the function
1 Like

Omg. :flushed: Didn’t even notice, that worked thanks but now the bar is just stuck and I’m getting this error, any thoughts on what the error is


?
image

Nevermind, figured it out and fixed. Thanks alot @JamesBlossoms and @Fogronic

1 Like

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