Tween size and position is broken

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()

Set the anchor point on the loading bar to 0,0. You must have set it to 0.5,0.5

Also TweenSize() is deprecated, which is why your bar isn’t filling up completely. Use TweenService:Create() instead

1 Like

I didn’t read that much on dev forum to learn about tweenserver:create completely so I’m using tweensize:()
I’ll check it later by the way tnx for your help!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.