The TextLabel “percentageCounter” seemingly disappears immediately for no reason (as far as know).
Details:
LocalScript:
--LocalScript
function preloadAssets()
local assetCounter = assetloadingBKGR.assetCounter
local PercentageCounter = assetloadingBKGR.percentageCounter
local loadingWheel = assetloadingBKGR.loadingWheelBKGR
local assets = game.Workspace:GetDescendants()
local loadingWheelTween = game.TweenService:Create(loadingWheel, TweenInfo.new(1.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out, -1, false, 0.5), {Rotation = loadingWheel.Rotation + 360})
loadingWheelTween:Play()
for i, asset in ipairs(assets) do
local percentage = math.ceil((i / #assets) * 100) / 100
game.ContentProvider:PreloadAsync({asset})
--assetCounter.Text = "Loading Assets: ".. i .."/" ..#assets
PercentageCounter.Text = string.format("%.2f", percentage)
game.TweenService:Create(Bar, TweenInfo.new(0.1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {Size = UDim2.new(percentage, 0, 1, 0)}):Play()
task.wait()
end
tweenModule.tweenTransparencyPlayFn(assetloadingBKGR, 1, 1.5, "Sine", 2)
loadingWheelTween:Cancel()
end
ModuleScript (the tweenModule):
local module = {}
function module.tweenTransparencyPlayFn(parentInstance: Instance?, transparencyValue: number, tweenDuration: number, easingStyle: string, tweenDelay: number, includeParentInstance: boolean?, includeBKGRtransparency: boolean?, waitForTweens: boolean?)
local array = parentInstance:GetDescendants()
if includeParentInstance then table.insert(array, parentInstance) end
for i, instance in ipairs(array) do
local propertiesToTween = {}
if pcall(function() return instance.Transparency end) then
propertiesToTween["Transparency"] = transparencyValue
elseif instance.Name == "percentageCounter" then
propertiesToTween["TextTransparency"] = transparencyValue
elseif instance:IsA("GuiLabel") or instance:IsA("TextLabel") then
propertiesToTween["TextTransparency"] = transparencyValue
elseif instance:IsA("Frame") and includeBKGRtransparency then
propertiesToTween["BackgroundTransparency"] = transparencyValue
else
continue
end
--pcall(function() instance.Visible = true instance.Active = true end)
local tweenInfo = TweenInfo.new(tweenDuration, Enum.EasingStyle[easingStyle], Enum.EasingDirection.In, 0, false, tweenDelay or 0)
local tweenPlay = game.TweenService:Create(instance, tweenInfo, propertiesToTween)
tweenPlay:Play()
if i == #array and waitForTweens then
tweenPlay.Completed:Wait()
end
end
end
return module
The elseif instance.Name == "percentageCounter" then
was a temporary solution, now it comes back to haunt me again.
Hierarchy: