I’ve been trying to make a custom loading screen for one of my upcoming games but it keeps on getting errors again & again. I have tried asking the AI assistant to re-write the script and have completly sourced the entire script from the developer documentation.
So Basically Whenever i change the value of both the MainLoader
& The MainMenu
to script.parent.parent
(as in the code below) from game.StarterGUI.MainLoader
/MainUI) the LoadingBar(TweenService) Doesn’t work. However, when I keep atleast on of them as game.StarterGUI.MainLoader
/MainUI the tween service works. For example:
The tweenservice works with these values:
local MainMenus = script.Parent.Parent.Parent.Parent.MainUI
local MainLoader = game.StarterGUI.MainLoader
local MainMenus = game.StarterGUI.MainUI
local MainLoader = script.Parent.Parent.Parent
local MainMenus = game.StarterGUI.MainUI
local MainLoader = game.StarterGUI.MainLoader
But it doesnt work with:
local MainMenus = script.Parent.Parent.Parent.Parent.MainUI
local MainLoader = script.Parent.Parent.Parent
Here’s the code:
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local ContentProvider = game:GetService("ContentProvider")
local TweenService = game:GetService("TweenService")
local Background = script.Parent
local UIS = game:GetService("UserInputService")
local GUIService = game:GetService("GuiService")
local MainMenus = script.Parent.Parent.Parent.Parent.MainUI
local MainLoader = script.Parent.Parent.Parent
local LDecal = script.Parent.Parent.Loader
ReplicatedFirst:RemoveDefaultLoadingScreen()
local assets = game.Workspace:GetDescendants()
MainLoader.Enabled = true
for i = 1, #assets do
local asset = assets[i]
local percentage = math.floor(i / #assets * 100)
ContentProvider:PreloadAsync({asset})
Background:WaitForChild("AssetsLoaded").Text = "Loading Assets: "..i.." of "..#assets.." ("..percentage.."%)"
TweenService:Create(Background.LoadingBar.Bar, TweenInfo.new(0.2,Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Size = UDim2.fromScale(percentage/100, 1)}):Play()
if i % 25 == 0 then
task.wait()
end
if i % 50 == 0 then
task.wait()
end
if i % 75 == 0 then
task.wait()
end
if i % 97 == 0 then
task.wait()
end
end
wait()
Background:WaitForChild("AssetsLoaded").Text = "Loading Complete!"
task.wait(3)
MainMenus.Enabled = true
task.wait(1)
LDecal.Visible = true
task.wait(5)
MainLoader.Enabled = false
Here’s a SS of the explorer if it might help(refer to the Handler
script under MainFrame
)
Been trying to figure it out since some time but couldnt find any errors… tried searching for it but nothing came up. Any help will be appriciated, Thanks.