Trying to make a loading screen , error

Why wont the background work, I am trying to make a loading screen that fills the background, this achieves by having the logo a bit transparent and the background not transparent. Then a textlabel with the color you want the logo to be filled in with would grow using Udim2 , but I can’t figure out what is the issue with this script, it wont work.

local prog = 0

while wait() do
	prog = prog + 0.5
	script.Parent.Size = UDim2.new(prog)
   while wait() do
	prog = prog*2
end
	if prog == 50 then
		wait(1)
		script.Parent.Parent:Destroy()
	end
end

Udim2 requires 4 parameters Udim2.new(x, x, y, y)

1 Like

here

local x = 0;
local div = 1000;--each division between a movement.
local transp = --thing you want to make transparent
for i = 1, div do
	wait(1/div);
	script.Parent.Size = UDim2.new(div/1000,0,1,0);--the entire screen of height.
	transp.Transparency = div/1000;
end

game.Debris:AddItem(script.Parent,0)
4 Likes

The nested loops could be causing issues, it appears there is no way out of your second one.

I would try Robloxs TweenService:Create to control the growing label instead

…or a more controlled loop like @Gagou_Bloxxer posted while I was typing this :wink:

1 Like

Uh or Just label:Tweensize method

script.Parent:TweenSize(UDim2.new(1,0,1,0), 'Out', 'Quad', 2);

wait(2)

game.Debris:AddItem(script.Parent,0)
2 Likes

Thank you!

I’d say it would be better if you’d utilise this into a proper loading screen.
You can use the ContentProvider service and use .RequestQueueSize to see what assets have to load.

Somewhere at the top of the script you’d want to set the initial queue size it has to load and use that as a foundation to use your load screen.

local TotalAmountofAssets = game:GetService("ContentProvider").RequestQueueSize

This would return an int value of the amount of assets which need to be loaded.
You can have a loop which keeps getting the amount of assets left needed to load and divide it by the total amount of assets:

local Progress =  ContentProvider.RequestQueueSize/TotalAmountofAssets

This would be a number between 0 and 1 so you can use it in your loading UI:

Bar:TweenSize(UDim2.new(Progress,0,1,0), 'InOut', 'Sine')

Make sure not to have this loop go on forever, if it doesn’t fully load. You can have a skip button after a certain amount of seconds.

The GuiObject Tween properties are terrible and legacy. TweenService should be used in place of GuiObject Tween methods, since TweenService can do everything those methods can and more.

See: