Progress bar only loading halfway

I’ve been working on a game with a few friends and I’ve come across a problem which plagues all of us.
It comes in the form of a UI, where I found and modified a script to work with it and for the most part it works and loads based on the assets ingame, however the progress bar only fills about half way.

image
The Picture above shows the number of assets being loaded and the progress bar which is as stated above only a quarter of the way complete

Below is the modified script, and it should get the number of assets to load and then is supposed to tween the progress bar based on how many assets have been loaded.

local loadables = workspace:GetDescendants() -- Assets to Load

local thread = coroutine.running()
local amount_loaded = 0

for i = 1, #loadables do
	coroutine.wrap(function()
		ContentProvider:PreloadAsync({loadables[i]})
		amount_loaded = amount_loaded + 1
		coroutine.resume(thread)
	end)()
end

while amount_loaded ~= #loadables do
	coroutine.yield()
	loading_text.Text = amount_loaded .."/"..#loadables
	loading_text.TextSize = 12
	--loading_bar.Size = UDim2.new(--[[amount_loaded/#loadables]]9.215,0,0.413,0)
	loading_bar:TweenSize(UDim2.new(amount_loaded/#loadables,0,1,0))
	print(#loadables)
end

I’m not sure whats causing this problem but any help would be necessary.

Hmm. My idea is that there isn’t enough time to tween, and it ends up being delayed. Have you tried doing this without tweening, just to see if it works?

1 Like

Yea, thanks for that. I hadn’t ever considered tween times

1 Like

Make sure to have a wait inside of that while loop though.

you can also try lerping, not sure if it works but it could. :upside_down_face: