-
What do you want to achieve? Keep it simple and clear!
So exactly, my loading script and process tooks forever to load. It is around 48k parts in full game.
And this loading is already like 5-10 mins -
What is the issue? Include screenshots / videos if possible!
Loading takes too much - What solutions have you tried so far? Did you look for solutions on the Developer Hub? That’s code i wrote by myself, though now i see it kinda not optimised.
Code:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local ContentProvider = game:GetService("ContentProvider")
local TweenService = game:GetService("TweenService")
local LoadGame = workspace:WaitForChild("Events").LoadGame
local Assets = game:GetDescendants()
local UI1 = script.LoadingGUI:Clone()
local camera = workspace.CurrentCamera
local Player = game:GetService("Players").LocalPlayer
local pName = Player.Name
local PlayerGui = Player:WaitForChild("PlayerGui")
ReplicatedFirst:RemoveDefaultLoadingScreen()
local instance = Instance.new("BoolValue")
instance.Name = "isLoading"
instance.Parent = Player
instance.Value = true
UI1.Parent = PlayerGui
for i=1, #Assets do
local asset = Assets[i]
ContentProvider:PreloadAsync({asset})
UI1.MainFrame.Loading.ProgressBar.AssetLabel.Text = "Loading Assets..."..asset.Name.." ("..i.."/"..#Assets..")"
UI1.MainFrame.Loading.ProgressBar.Filler:TweenSize(UDim2.new(1/(#Assets/i), 0, 1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.1, false)
if #Assets/i == 1 then
UI1.MainFrame.Loading.ProgressBar.Filler:TweenSize(UDim2.new(1, 0, 1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.1, false)
end
end
local Character = workspace:FindFirstChild(pName)
Character:WaitForChild("Humanoid").WalkSpeed = 0
Character:WaitForChild("Humanoid").JumpPower = 0
instance.Value = false
UI1.MainFrame:TweenPosition(UDim2.new(-1.5, 0, 0, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 2, false, function()
UI1.MainFrame.Visible = false
for _,drops in pairs(UI1.MainFrame.Loading.DropsFolder:GetChildren()) do
drops:Destroy()
end
UI1.Menu.LoadingLabel:TweenPosition(UDim2.new(0.25, 0, 0.3, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.5, false, function()
UI1.Menu.PlayButton:TweenPosition(UDim2.new(0.25, 0, 0.4, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.5, false, function()
UI1.Menu.DonateMenuButton:TweenPosition(UDim2.new(0.25, 0, 0.525, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.5, false, function()
UI1.Menu.SettingsButton:TweenPosition(UDim2.new(0.25, 0, 0.65, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.5, false, function()
end)
end)
end)
end)
end)
UI1.Menu.PlayButton.TextButton.MouseEnter:Connect(function()
UI1.Menu.PlayButton.Hover.Visible = true
UI1.Menu.PlayButton.Hover:TweenSize(UDim2.new(1,0,0.5,1), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.5, true)
end)
UI1.Menu.DonateMenuButton.TextButton.MouseEnter:Connect(function()
UI1.Menu.DonateMenuButton.Hover.Visible = true
UI1.Menu.DonateMenuButton.Hover:TweenSize(UDim2.new(1,0,0.5,1), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.5, true)
end)
UI1.Menu.SettingsButton.TextButton.MouseEnter:Connect(function()
UI1.Menu.SettingsButton.Hover.Visible = true
UI1.Menu.SettingsButton.Hover:TweenSize(UDim2.new(1,0,0.5,1), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.5, true)
end)
UI1.Menu.PlayButton.TextButton.MouseLeave:Connect(function()
UI1.Menu.PlayButton.Hover:TweenSize(UDim2.new(1,0,0,1), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.5, true, function()
UI1.Menu.PlayButton.Hover.Visible = false
end)
end)
UI1.Menu.DonateMenuButton.TextButton.MouseLeave:Connect(function()
UI1.Menu.DonateMenuButton.Hover:TweenSize(UDim2.new(1,0,0,1), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.5, true, function()
UI1.Menu.DonateMenuButton.Hover.Visible = false
end)
end)
UI1.Menu.SettingsButton.TextButton.MouseLeave:Connect(function()
UI1.Menu.SettingsButton.Hover:TweenSize(UDim2.new(1,0,0,1), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.5, true, function()
UI1.Menu.SettingsButton.Hover.Visible = false
end)
end)
UI1.Menu.PlayButton.TextButton.MouseButton1Click:Connect(function()
UI1.Menu.LoadingLabel:TweenPosition(UDim2.new(0.25, 0, -1.3, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.5, false, function()
UI1.Menu.PlayButton:TweenPosition(UDim2.new(0.25, 0, -1.4, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.5, false, function()
UI1.Menu.DonateMenuButton:TweenPosition(UDim2.new(0.25, 0, -1.525, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.5, false, function()
UI1.Menu.SettingsButton:TweenPosition(UDim2.new(0.25, 0, -1.65, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.5, false, function()
LoadGame:FireServer()
end)
end)
end)
end)
end)
print("Done")
Note: I don’t ask for full script rewriting, just some tips about optimization, like spending 30 mins for SMALL game load it is very much