Loading script randomly stops

So I have this loading script for my game here:

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
local Frame = script.Parent.Loading
local Base = Frame.Base
local Bar = Base.Bar
local Indicator = Base.Indicator
local Shadow = Indicator.Shadow
local ImageLabel = Frame.ImageLabel
local TextLabel = Frame.TextLabel
local queueservice = game:GetService("ContentProvider")
local queue = queueservice.RequestQueueSize
local RunButton = game.Players.LocalPlayer.PlayerGui:WaitForChild("ResetableGui")["Run Button"]
local RunButtonEffect = game.Players.LocalPlayer.PlayerGui:WaitForChild("ResetableGui")["Run Button Effect"]
local FeedbackButton = game.Players.LocalPlayer.PlayerGui:WaitForChild("UnresetableGui")["Feedback Button"]
local FeedbackButtonEffect = game.Players.LocalPlayer.PlayerGui:WaitForChild("UnresetableGui")["Feedback Button Effect"]
local SettingsButton = game.Players.LocalPlayer.PlayerGui:WaitForChild("UnresetableGui").SettingsButton
local InventoryButton = game.Players.LocalPlayer.PlayerGui:WaitForChild("UnresetableGui").InventoryButton
local TeleportButton = game.Players.LocalPlayer.PlayerGui:WaitForChild("ResetableGui").TeleportButton
local ToggleQuestsButton = game.Players.LocalPlayer.PlayerGui:WaitForChild("UnresetableGui").QuestsButton
local TogglePromocodesButton = game.Players.LocalPlayer.PlayerGui:WaitForChild("UnresetableGui").PromoCodesButton
local TestBlock = game.Players.LocalPlayer.PlayerGui:WaitForChild("UnresetableGui").TestPlaceBlock
TestBlock.Visible = false
FeedbackButton.Visible = false
FeedbackButtonEffect.Visible = false
RunButton.Visible = false
RunButtonEffect.Visible = false
TeleportButton.Visible = false
SettingsButton.Visible = false
InventoryButton.Visible = false
ToggleQuestsButton.Visible = false
TogglePromocodesButton.Visible = false
Frame.Visible = true
game.ReplicatedFirst:RemoveDefaultLoadingScreen()

local loadables = game:GetChildren()

local amount_loaded = 0

for i = 1, #loadables do
	queueservice:PreloadAsync({loadables[i]})
	amount_loaded = i
	Indicator.Text = "Loading Assets ".. i.."/"..#loadables
	Shadow.Text = "Loading Assets ".. i.."/"..#loadables
	Bar.Size = UDim2.new(amount_loaded/#loadables,0,1,0)
	print("loading") --Debugging the issue
	if Bar.Size == UDim2.new(1,0,1,0) then
		Frame.Visible = false
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
		wait(0.01)
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.EmotesMenu, false)
		wait(1)
		FeedbackButton.Visible = true
		FeedbackButtonEffect.Visible = true
		RunButton.Visible = true
		RunButtonEffect.Visible = true
		SettingsButton.Visible = true
		InventoryButton.Visible = true
		TeleportButton.Visible = true
		ToggleQuestsButton.Visible = true
		TogglePromocodesButton.Visible = true
		game.Players.LocalPlayer.PlayerGui:WaitForChild("UnresetableGui").Message.Visible = true
		game.Players.LocalPlayer.PlayerGui:WaitForChild("UnresetableGui").Message.ConfirmButton.LocalScript.Disabled = false
		game.Players.LocalPlayer.PlayerGui:WaitForChild("UnresetableGui").ChristmasStampsContainer.Visible = true
		script.Parent:Destroy()
	end
end

The script starts loading, but then stops at a specific number. In roblox studio, it’s 34/132 and in an actual server, it’s 27/96.

This never happened to me before. I don’t remember changing anything in this script.

The output of this script is “loading”, and it’s being printed 34 times in studio or 27 in a server

Anything helps!

^^^^ This ^^^^
I don’t think you can use a preload on every single game asset in the game. This is most likely the cause of the problem imho.

1 Like

Don’t load every asset in the game, render them in the background.

Only have things you need to preload in preloadables because game has a lot of objects/instances within it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.