-
What do you want to achieve? make the loading gui come first, then once that is done, the intro gui is enabled
-
What is the issue? when i try to use this
local contentProvider = game:GetService("ContentProvider")
local replicatedFirst = game:GetService("ReplicatedFirst")
local gui = script.Parent
local loadingBar = gui.LoadingBar.Inner
local percentageLabel = gui.PercentLabel
local preloadableClassnames = {
Decal = true,
Sound = true,
Animation = true,
ParticleEmitter = true,
Beam = true,
Trail = true,
Texture = true,
ImageLabel = true,
ImageButton = true,
MeshPart = true,
SpecialMesh = true,
SurfaceApperance = true,
Shirt = true,
Pants = true,
Blur = true,
ColorCorrection = true,
DepthOfField = true,
SunRays = true,
Lighting = true
}
local toPreload = {}
local count = 0 -- Counts how much assets have been loaded
local loaded = false -- Boolean that says if we finished loading
local workspaceContent = workspace:GetDescendants()
local replicatedFirstContent = replicatedFirst:GetDescendants()
local Player = game.Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local lobby = PlayerGui.lobbygui
table.move(replicatedFirstContent, 1, #replicatedFirstContent, #workspaceContent + 1, workspaceContent) -- Combines content of Workspace and ReplicatedFirst into single table
replicatedFirst:RemoveDefaultLoadingScreen()
for i, v in workspaceContent do -- Loop threw combined content
if typeof(v) == "Instance" and preloadableClassnames[v.ClassName] then -- Check thats content is preloadable
table.insert(toPreload, v) -- Insert content into final table
end
end
local function preloadAsset(asset: Instance)
contentProvider:PreloadAsync({asset})
count += 1
local ratio = count / #toPreload
loadingBar.Size = UDim2.fromScale(ratio, 1)
percentageLabel.Text = math.floor(ratio * 100) .. "%"
end
local function Preload()
for i, v in toPreload do
task.spawn(preloadAsset, v)
end
while count < #toPreload or not game:IsLoaded() do
task.wait()
end
loaded = true
gui.Enabled = false
lobby.Enabled = true
end
gui.Enabled = true
lobby.Enabled = false
task.spawn(Preload)
it doesnt work. specifically, the loading screen doesnt work with
local Player = game.Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local lobby = PlayerGui.lobbygui
--
lobby.Enabled = true
--
lobby.Enabled = false
without that it worked perfectly fine
- What solutions have you tried so far? i tried looking around on devforum but it seems this is a very specific issue. . .
without enabling
robloxapp-20240417-1813352.wmv (137.8 KB)
with enabling
robloxapp-20240417-1815209.wmv (403.5 KB)
(sorry you have to download those)
im not a scripter if you cant tell, sorry if this was really obvious