Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My loading screen doesn't work correctly? Also, what does % do in the second script?

It's pretty simple and I decided to just add Tweening but I get a Userdata error on line 8 of my script. I'd love a well detailed answer

Here's the script:

script.Parent:RemoveDefaultLoadingScreen()
 
local LoadingScreen = game.ReplicatedFirst.ScreenGui:Clone()
LoadingScreen.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
 

while game.ContentProvider.RequestQueueSize > 0  do
	LoadingScreen.Frame:TweenPosition(UDim2.new(0,0, -8,0) "Out", "Linear", 2, true)
	LoadingScreen.Frame:TweenPosition(UDim2.new(0,0, 8,0) "Out", "Linear", 2, false)
	
end

script.LoadingScreen:remove()

My ScreenGui is inside of ReplicatedFirst along with the LocalScript. There's no scripts inside of the ScreenGui! Also in the tutorial I saw a percentage sign "%" and wondered what this does, so if this can also be answered, Thanks.

This is the Wiki's script:

script.Parent:RemoveDefaultLoadingScreen()
 
local screen = Instance.new("ScreenGui")
screen.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
 
local textLabel = Instance.new("TextLabel")
textLabel.Parent = screen
textLabel.Text = "Loading"
textLabel.Size = UDim2.new(1,0,1,0)
textLabel.FontSize = Enum.FontSize.Size14
 
local count = 0
while game.ContentProvider.RequestQueueSize > 0  do
	textLabel.Text = "Loading " .. string.rep(".",count)
	count = (count + 1) % 4
	wait(.3) 
end
 
screen.Parent = nil

2 comments

0

The use of the modulus(%) operator here is to only allow 3 dots maximum when displaying the loading text.

1 answer

You forgot commas after your UDim2 values!

LoadingScreen.Frame:TweenPosition(UDim2.new(0,0, -8,0), "Out", "Linear", 2, true)	-- Line 8
LoadingScreen.Frame:TweenPosition(UDim2.new(0,0, 8,0), "Out", "Linear", 2, false)

You can't combine two different types of values. A value type that combines UDim2 and EasingDirection Enum value doesn't exist!

Reference Link

Also, the % operator returns the remainder of the dividend & the divisor.

  • 11 / 2 == 5.5 OR 5 remainder 1

With the remainder of 1 in mind, hence:

  • 11 % 2 == 1

This discussion is preserved as it was. New answers, comments, and votes are closed.