Hi developers! I have stumbled upon a problem and have found no solutions! Hope you can help. (Sorry if this is messy, this is my first post!)
What I’m Doing
I’ve been making a simple GUI loading screen.
The actual loading script works fine! Here is my script:
wait(1) -- Let things load in
script.Parent.Enabled = true
local Loading = script.Parent.Loading
local Back = Loading.Back
local Front = Loading.Front
local Player = game.Players.LocalPlayer
repeat wait() until Player.Character
local WA = {} -- WA = Workspace Amount
Front.Size = UDim2.new(0,0,1,0)
Front.BackgroundColor3 = Color3.new(25/255,25/255,25/255)
local function Scan(this)
for i, v in pairs(this:GetDescendants()) do
table.insert(WA, v)
end
end
local Service = {
"Lighting",
"InsertService",
"ContentProvider",
"CollectionService",
"RunService",
"SoundService",
"BadgeService",
"Selection",
"GuiService",
"UserInputService",
"Debris",
"TeleportService",
"Chat",
"PhysicsService",
"AssetService"
}
for i=0, #Service, 1 do
game:GetService(tostring(Service[i]))
end
Scan(game.Players)
Scan(game.StarterGui)
for i=0, #Service, 1 do
if game:GetService(tostring(Service[i])) ~= nil then
Scan(game:GetService(tostring(Service[i])))
end
end
for i=0, #WA, 1 do
Front.Size = UDim2.new(i/#WA+0.055, 0, 1, 0)
if WA[i] ~= nil then
Loading.Text = " Loading: " .. tostring(WA[i])
end
wait(0.04)
end
Loading.Text = " Loading: Completed."
script.Parent.BG.Done.Visible = true
local function RGB(r,g,b)
return Color3.new(r/255,g/255,b/255)
end
local Color = Front.BackgroundColor3
for i=Color.r, 15, -1 do
Front.ImageColor3 = RGB(i,i,i)
wait(0.07)
end
wait()
for i=15, 25, 1 do
Front.ImageColor3 = RGB(i,i,i)
wait(0.05)
end
Problem 1
I have 2 problems! One my problems are that the UI comes up again every single time you spawn in. Here is the script used to load the UI for the player.
local loadgui = script.loadingGUI:Clone()
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:wait()
loadgui:Clone().Parent = player.PlayerGui
end)
I also guess I should show you what it looks like in the explorer…
Problem 2
It takes WAY too long! It loads so many individual objects!
Have I actually Tried to fix it?
Yes. I looked around YT and the DevForum and found nothing which helped me with the situation.
Thanks for reading everyone! If you could reply some help I would love that! I’m VERY new to scripting so sorry if I sound like a noob…
Edit 1: Just correcting a part a said twice by accident
Edit 2: Problem 1 was solved!