i’m back and need more help with things i got no clue how to do B)
So, I got my loading screen to function as intended, using the script from this post as a heavy base.
However, I also want to add in a skip loading button in the GUI, for the sake of my staff and just the general fact that you don’t have to load EVERYTHING in the game to play it.
For context, here’s how I’ve got these named + layered:
I tried doing it via the simplest method I could think of, via putting a local script in the TextButton and basically doing:
local button = script.Parent
local gui = PlayerGui.LoadGui
button.MouseButton1Click:Connect(function()
gui.Enabled == false
end)
This, of course, didn’t work. Doing some searching, I came upon this thread, which implements the skip button via pressing the spacebar, but notably puts the skip script into the loading GUI script itself.
It’s reliant on a break, which I’m not too sure how to work into my existing loading screen script.
Here is my script named “Loading”:
local ContentProvider = game:GetService("ContentProvider")
local toLoad = Workspace -- Replace workspace with what you need to load
local assetsTable = toLoad:GetDescendants()
local totalAssets = #assetsTable
local assetsLoaded = 0
local Gui = script.Parent
local Bar = Gui:WaitForChild("Background"):WaitForChild("BarBackground"):WaitForChild("Bar")
local Text = Gui:WaitForChild("Background"):WaitForChild("Text")
Gui.Enabled = true
for i = 1, totalAssets do
pcall(function() -- You don't need pcall if you are not loading the whole game
ContentProvider:PreloadAsync({assetsTable[i]})
assetsLoaded = i
Bar.Size = UDim2.new(i/totalAssets, 0, 1, 0)
Text.Text = "Loading: " .. i .. " / " .. totalAssets .. " "
print(assetsLoaded)
end)
end
Text.Text = "Loaded!"
wait(2)
Gui.Enabled = false
print("All assets loaded.")
^ This works as intended. I just want to add a skip button that will close the GUI.
Help would be great. I’m just not too sure how to work it in, and I’ve tried a few ways, I just don’t really get what I’m doing either.
As always, I’m autistic, please be patient with me. I may need further explanation or things to be reworded so I can understand them.