Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with creating an AssetLoader Gui? [closed]

Asked by 6 years ago
Edited 6 years ago

This "Asset Loader" is basically a timed loading screen. When I wrote the code for it I wasn't taking into account that everyone's computer and WiFi greatly differ so some players may load the game faster than others. I have 0 experience with asset loaders and I don't even know where to begin. I want the asset loader to actually wait for the assets to be loaded but I have no idea how to do this. Can someone help/point me in the right direction? Links to tutorials, wiki anything will help.

Code:

local time = 0

repeat
    wait(0.35)
    time = time + 1
    script.Parent.Text = "Loading Assets: "..time.."%"
until time == 100

wait (2)

script.Parent.Text = "Loading Complete"

wait (4)

script.Parent.Transparency = .1
wait(0.1)
script.Parent.Transparency = .2
wait(0.1)
script.Parent.Transparency = .3
wait(0.1)
script.Parent.Transparency = .4
wait(0.1)
script.Parent.Transparency = .5
wait(0.1)
script.Parent.Transparency = .6
wait(0.1)
script.Parent.Transparency = .7
wait(0.1)
script.Parent.Transparency = .8
wait(0.1)
script.Parent.Transparency = .9
wait(0.1)
script.Parent.Transparency = 1

--[[
script.Parent.Parent.MainBox.Visible = true 
wait (1)    
script.Parent.Parent.MainBox.Blue:TweenSize(UDim2.new(1,0,1,0),"In","Linear", 1)
wait (1)
script.Parent.Parent.MainBox.Green:TweenSize(UDim2.new(1,0,1,0),"In","Linear", 1)
wait (1)
script.Parent.Parent.MainBox.Red:TweenSize(UDim2.new(1,0,-1,0),"In","Linear", 1)
wait (1)
script.Parent.Parent.MainBox.White:TweenSize(UDim2.new(-1,0,1,0),"In","Linear", 1)
wait (1)
script.Parent.Parent.MainBox.White.Visible = false
script.Parent.Parent.MainBox.Blue.Visible = false
script.Parent.Parent.MainBox.Green.Visible = false
script.Parent.Parent.MainBox.Red.Visible = false
wait (1) ]]
script.Parent.Parent.MainBox.Parent.BlackBar:TweenSize(UDim2.new(1,0,0.5,0),"In","Linear", 0.5)
script.Parent.Parent.MainBox.Parent.GrayBar:TweenSize(UDim2.new(-1,0,0.5,0),"In","Linear", 0.5)
wait (1)
script.Parent.Parent.MainBox.Parent.BlackBar:TweenSize(UDim2.new(-1,0,0.5,0),"In","Linear", 0.5)
script.Parent.Parent.MainBox.Parent.GrayBar:TweenSize(UDim2.new(1,0,0.5,0),"In","Linear", 0.5)
script.Parent.Parent.BackgroundTransparency = 1
script.Parent.Parent.MainBox.Visible = false
wait(0.5)
script.Parent.Parent.MainBox.Visible = false
script.Parent.Parent.Visible = false

Locked by MessorAdmin, Mayk728, Vulkarin, and TheeDeathCaster

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 6 years ago

I write this quickly and didn't test it. Let me know if theirs any issues.

Heres the wiki article for more info: http://wiki.roblox.com/index.php?title=API:Class/ContentProvider

wait()

local TimeOut = false -- In case the user has like DSL or something
local Ceil = math.ceil -- rounding

local TextLabel = script.Parent
local MainBox = (TextLabel.Parent).MainBox
 local Blue = MainBox.Blue
 local Green = MainBox.Green
 local Red = MainBox.Red
 local White = MainBox.White

local ContentProvider = game:GetService("ContentProvider") -- Check the wiki page for more
local Assets = {
    0000000,
    0000000,
    0000000,
}

TextLabel.Text = "Loading please wait"

delay(8,function()
    TimeOut = true
end)
spawn(function() -- Heres the part that loads all the IDs in the array above
    for _,v in next,Assets do
        ContentProvider:PreloadAsync({"rbxassetid://"..v})
        wait()
    end
end)

-- Our actual asset loading check
repeat wait()
    local ratio = Ceil( current / #Assets )
    TextLabel.Text = "Loading please wait "..tostring(ratio).."%"
until ((ContentProvider.RequestQueueSize<=0) or TimeOut==true)

TextLabel.Text = "Loading complete"

for i = 0,1,0.1 do -- Your text fading
    TextLabel.TextTransparency = i
    TextLabel.TextStrokeTransparency = i
    wait()
end

MainBox.Parent.BlackBar:TweenSize(UDim2.new(1,0,0.5,0),"In","Linear", 0.5)
MainBox.Parent.GrayBar:TweenSize(UDim2.new(-1,0,0.5,0),"In","Linear", 0.5)
wait (1)
MainBox.Parent.BlackBar:TweenSize(UDim2.new(-1,0,0.5,0),"In","Linear", 0.5)
MainBox.Parent.GrayBar:TweenSize(UDim2.new(1,0,0.5,0),"In","Linear", 0.5)
TextLabel.Parent.BackgroundTransparency = 1
TextLabel.Parent.MainBox.Visible = false
wait(0.5)
MainBox.Visible = false
TextLabel.Parent.Visible = false
0
Is there a way I could just load the objects in workspace? Michael_TheCreator 166 — 6y
0
Yes, put the model into ServerStorage then use a for i loop to put it into workspace MessorAdmin 598 — 6y
0
Thank you Michael_TheCreator 166 — 6y
Ad