I was using UDim2.new to change the size and position of my loading screen bar after that I decided to use the tween service to give it some animations and
This is the result:
It was working with UDim2 before
this is the script:
local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local ContentProvider = game:GetService("ContentProvider")
ReplicatedFirst:RemoveDefaultLoadingScreen()
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local loadingScreen = script:WaitForChild("LoadingScreen"):Clone()
loadingScreen.Parent = PlayerGui
local frame = loadingScreen:WaitForChild("Frame")
local loadingText = frame:WaitForChild("TextLabel")
local bar = frame:WaitForChild("LoadingBar"):WaitForChild("Bar")
local assets = game:GetChildren()
local TweenService = game:GetService("TweenService")
for index, asset in pairs(assets) do
loadingText.Text = "Loading "..asset.Name.."..."
ContentProvider:PreloadAsync({asset})
local progress = index / #assets
bar:TweenSize(
UDim2.new(progress, 0, 1, 0),
"Out",
"Quad",
.25,
false
)
end
loadingText.Text = "LOADING COMPLETE!"
bar:TweenSize(
UDim2.new(1, 0, 1, 0),
"Out",
"Quad",
.25,
false
)
bar.Position = UDim2.new(.5, 0, .5, 0)
task.wait(2)
loadingScreen:Destroy()