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.