Ad
Log in to vote
0

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

Asked by 7 years ago

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
0
The use of the modulus(%) operator here is to only allow 3 dots maximum when displaying the loading text. Lacryma 548 — 7y

1 answer

Log in to vote
1
Answered by
Redbullusa 1580 Moderation Voter
7 years ago

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
Ad

Answer this question