I've always wondered how some developers do this, and now that i'm making a game where things load, and i would like users to see a loading screen.
Can someone inform me on how a loading bar works? I know it has something to do with resizing it, with like a Cframe *1, or something like that.
What you are referring to is Tweening. It lets you change the size, position, or both at the same time. It allows you to have an end and start position that has a "sliding" feature to it. The syntax for TweenSize is, gui:TweenSize( UDim2 endSize, Enum easingDirection = Out, Enum easingStyle = Quad, float time = 1, bool override = false, function callback = nil )
Let me explain what each of these things do,
The end size is the size you want to expand to.
The easing direction is the "way it slides". For example, "In" would make it slow down as it comes in.
The easing style is the way it expands there, or "the way in which the tweening will act". For example, a "Linear" easing style would remain constant; however, a "Sine" tweening style will "gradually slow down" until the endpoint is reached.
The float time is how long it will take to reach the end point (in seconds).
To make a "loading GUI" you would want to do something similar to this,
gui:TweenSize(UDim2.new(0, 100, 0, 0), "Out", "Linear", 2, false)
If the start size was (0, 0, 0, 0) this would expand along the x-axis with an offset of 100 and would take two seconds to reach that size.
I believe most loading bars are for decoration, but some of it actually loads stuff as images etc.
if you wish to know how to make one look at this demo. http://www.roblox.com/Loading-Bar-Demo-item?id=150398813
This has a loading GUI with the loading bar you want, It also has a cool extra effect,
function added(player)
local NameOfGame = "NameHere" -- Change the bit in the speach marks to the name of your game.
RotationMode = false -- Set this to true if you want it to rotate. ShakeMode = true -- This makes it shake like a earthquake! Set to true if you want to do this. ClassicLoading = true -- This adds an epic bit at the beggining. Set to false if you dont want this. local GUI = script.IntroGUI:clone() GUI.Parent = player:WaitForChild("PlayerGui") local Frame = GUI.Frame local Text = Frame.TextLabel local ClassicLoad = Frame.ClassicLoadFrame local LoadText = ClassicLoad.LoadText Text.Visible = false repeat wait() until player.Character player.Character.Torso.Anchored = true Text.TextTransparency = 1 Text.Text = NameOfGame Text.Visible = true Percent = 0 wait(5) if ClassicLoading == true then ClassicLoad:TweenSize(UDim2.new(1, 0, 0, 200), "Out", "Quad", 5) while Percent < 100 do Percent = Percent + 1 LoadText.Text = Percent .. "%" wait(5/100) end wait(1) while ClassicLoad.BackgroundTransparency < 1 do ClassicLoad.BackgroundTransparency = ClassicLoad.BackgroundTransparency + 0.05 LoadText.TextTransparency = LoadText.TextTransparency + 0.05 wait() end wait(1) end while Text.TextTransparency > 0 do Text.TextTransparency = Text.TextTransparency - .05 wait(.05) end wait(5) player.Character.Torso.Anchored = false while Frame.BackgroundTransparency ~= 1 do Text.Position = UDim2.new(.5, 0, .25, 0) if RotationMode == true then Text.Rotation = Text.Rotation + 10 end if ShakeMode == true then Text.Position = Text.Position + UDim2.new(0, math.random(-10, 10), 0, math.random(-10, 10)) end Frame.BackgroundTransparency = Frame.BackgroundTransparency + .05 Text.TextTransparency = Text.TextTransparency + .05 wait(.05) end
end game.Players.PlayerAdded:connect(added)