What do you want to achieve? I want the loading screen’s process bar to start moving
What is the issue? The loading screen’s process bar is not working at all. It’s either that the formula is wrong (but I’ve used the same formula for all my other bar scripts and they’ve worked perfectly) or just some other issue.
What solutions have you tried so far? I tried multiplying instead of adding but that tweened the GUI bigger in the Y axis. I also tried to put 1 as the Y scale, which is the size of the fill bar on the Y axis.
I’ve also tried using task.spawn() instead of just calling the function
local Assets = game:GetDescendants()
for count, asset in pairs(Assets) do
ContentProvider:PreloadAsync(
{asset},
function()
GUI.Contents.Lower.AssetsLoaded.Text = "Assets loaded: "..count
local Formula = UDim2.fromScale(count / #Assets + OldXScale, FillBar.Size.Y.Scale)
local BarTween = TweenService:Create(FillBar, TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Size = Formula})
BarTween:Play()
end
)
end
Does the AssetsLoaded text get updated? Is the issue in the bar itself or is the entire script flawed? Is the bar not moving at all or just doing it wrong?
I myself would put the things you have in the callback function after the ContentProvider:PreloadAsync() function.
Also, I’m not sure if it’s a good idea to tween for every single asset like that. The next tween will have started before the previous one finishes. Try just setting the bar’s size instead of tweening. It would look something like this:
local Assets = game:GetDescendants()
for count, asset in pairs(Assets) do
ContentProvider:PreloadAsync({asset})
GUI.Contents.Lower.AssetsLoaded.Text = "Assets loaded: "..count
local Formula = UDim2.fromScale(count / #Assets + OldXScale, FillBar.Size.Y.Scale)
FillBar.Size = Formula
end
local Assets = game:GetDescendants()
for count, asset in pairs(Assets) do
ContentProvider:PreloadAsync(
{asset},
function()
GUI.Contents.Lower.AssetsLoaded.Text = "Assets loaded: "..count
local Formula = UDim2.new(count / #Assets,0,FillBar.Size.Y.Scale,0)
local BarTween = TweenService:Create(FillBar,TweenInfo.new(0.2, Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0),{Size = Formula})
BarTween:Play()
end
)
end
True, but sometimes it is useful to try similar functions in case the other isn’t working for some strange reason. Plus, I’ve never used UDim2.fromScale() before lol.
PLUS, I don’t think you need to use OldScale. it will always update correctly. 499/1000 assets loaded and the X Scale would be 0.499 and 501/1000 assets loaded would make the X Scale 0.501. You don’t need to add OldScale.