Help with asset loading Gui

  1. What do you want to achieve? Keep it simple and clear!

I want to fix the code and make it functional again.
2. What is the issue? Include screenshots / videos if possible!

print(#m.assets)
for i=1, #m.assets do
	print(1)
	local asset = m.assets[i]
	print(2)
	m.contentProvider:PreloadAsync({asset})
	print(3)
	loadingScreen.Frame.Status.Text = "Loading Assets, ".. #m.assets - i .." Assets Left"
	print(4)
end
print(5)

so m.assets are a array of assets that is loaded in mainmodule m, the whole script works all fine week ago and now it simply dont work. I added some prints to debug and only length of m.assets, 1 and 2 are printed. The for loop dont continue furthermore and stays at the first iteration. The gui’s text didn’t change at all. Is it due to roblox update or what?

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Yes, but nothing seem to help and I debugged hard but nothing worked including removing some extra content from it.

If anyone may help me with this it will be my pleasure!

2 Likes

Btw length of assets printed is 1775, I simply have no idea why the loop is not working.

2 Likes

Is this the full script? and is m.assets
local m.assets = game:GetDescendants()

2 Likes

you can just give m.assets to :PreloadAsync() and theres no really need to wrap :PreloadAsync() into a loop

2 Likes

yes it is and it’s length is 1775,printing it properly prints the array of assets

good to know! but the problem here is that the for loop simply dont proceed.But I guess I will try your suggestion out later today since Im going to school!

then where is the require statement for your module. of course its not gonna work.

well I do require at the top of the script, I just didnt show it here. The frustrating part is that this script has been working totally fine for a long time already, and now after the roblox short shutdown now it breaks

please show us EVERYTHING! we can’t do anything without the full script, and we have been asking for the module!!!

Well wait actually I dont think if I just do preloadasync assets it’s not possible to do stuff like knowing hke much more assets I still have to load so i guess…

Oh Im sorry new to forum but I’m going to school (in my timezone) so I guess I can’t post it yet and I will post it asap when Im back at home

its fine just remember every time you need help post every script related to what isn’t working

So here is the module that runs the loadasset gui module,


--require mainframework--
local m = require(game:GetService("ReplicatedStorage").Modules.Universal.MainFramework)
local modules = m.modules
--end--

local GuiActionModule = {}

local AnimList = {
	
	loadingScreenIcon = {
		tweeninfo = TweenInfo.new(2, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut, 0, false, 1),
		tweentarget = {Size = UDim2.new(0,100,0,100), ImageTransparency = 0, Rotation = 0}
	},
	
	loadingScreenGlare = {
		tweeninfo = TweenInfo.new(2, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut, 0 ,false, 1),
		tweentarget = {Position = UDim2.new(0,-70,-0.158,0), BackgroundTransparency = 0.5}
	},
	
	loadingScreen = {
		tweeninfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut,0, false, 0),
		tweentarget = {Position = UDim2.new(-1,0,0,0)}
	}
	
}

local function Play(InstanceName, InstancePath)
	m.tweenService:Create(InstancePath, AnimList[InstanceName].tweeninfo, AnimList[InstanceName].tweentarget):Play()
end

--functions--
function GuiActionModule:loadClient()
	m.rf:RemoveDefaultLoadingScreen()
	local loadingScreen = m.rs.Components.Gui["Loading Screen"]:Clone()
	loadingScreen.Parent = m.plr.PlayerGui

	Play("loadingScreenIcon", loadingScreen.Frame.icon)
	Play("loadingScreenGlare", loadingScreen.Frame.Glare)
	modules.ClientAudioModule:Play("LoadScreenSFX", 10, false)
	
	print(#m.assets)
	for i=1, #m.assets do
		print(1)
		local asset = m.assets[i]
		print(2)
		m.contentProvider:PreloadAsync({asset})
		print(3)
		loadingScreen.Frame.Status.Text = "Loading Assets, ".. #m.assets - i .." Assets Left"
		print(4)
	end
	print(5)
	
	require(m.plr:WaitForChild("PlayerScripts").PlayerModule):GetControls():Disable()
	m.rfunctions.PlayerFinishedLoading:InvokeServer()
	loadingScreen.Frame.Status.Text = "Loading Completed"
	
	Play("loadingScreen", loadingScreen.Frame)
	task.wait(0.5)
	loadingScreen:Destroy()
	
end
--end of functions--

return GuiActionModule

and the mainframework:


local m = {}

function m:Init()
	
	--services--
	
	m.plrs = game:GetService("Players")
	m.rf = game:GetService("ReplicatedFirst")
	m.rs = game:GetService("ReplicatedStorage")
	m.sp = game:GetService("StarterPlayer")
	
	m.tweenService = game:GetService("TweenService")
	m.contentProvider = game:GetService("ContentProvider")
	m.dataStoreService = game:GetService("DataStoreService")
	m.uis = game:GetService("UserInputService")
	m.cas = game:GetService("ContextActionService")
	m.https = game:GetService("HttpService")
	--end--
	
	--m variables--
	
	m.revents = m.rs.Events
	m.rfunctions = m.rs.Functions
	m.gui = m.rs.Components.Gui
	m.sounds = m.rs.Components.Sounds
	m.assets = game:GetDescendants()
	
	--check if module is used by server or client
	m.moduleGroup = nil
	if game.Players.LocalPlayer ~= nil then --if client
		m.plr = m.plrs.LocalPlayer
		m.mouse = m.plr:GetMouse()
		m.camera = workspace.CurrentCamera
		m.moduleGroup = {m.rs.Modules, m.rs.Modules.Universal}
	else
		m.ss = game:GetService("ServerStorage") --if server
		m.sss = game:GetService("ServerScriptService")
		m.moduleGroup = {m.sss.Core.Modules, m.ss.Modules, m.rs.Modules.Universal}
	end
	--end--
	
	--require modules--
	
	m.modules = {}
	for _, group in pairs(m.moduleGroup) do
		for _, instance in pairs(group:GetDescendants()) do
			if instance.ClassName == "ModuleScript" and instance.Name ~= script.Name then
				m.modules[instance.Name] = require(instance)
			end
		end
	end
	--end--
	
end

return m

i required the contentprovider in the mainframework as a variable to access, and assets containing all game:Descendants(), and then require the mainframework in the guiModule, inside runs a function that when fires loads the loadingScreen gui and loads game assets. The scripts works totally fine a few days ago and I didn’t do ANY major edits to both modules those days.

Nevermind all this, rescripted everything with a different frame and the problem had been resolved months ago. Totally forgot about this post. Also ContentProvider should not be used.

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