Tween does not change correctly

Local scirpt, gui:

local main = script.Parent
local player = game:GetService("Players").LocalPlayer

local function updateAll()
	main.progressBack.progressText.Text = player:WaitForChild("leaderstats").Damage.Value.. " / ".. main.forRebirth.Value
	main.progressBack.progressCurrent:TweenSize(UDim2.new(player:WaitForChild("leaderstats").Damage.Value / main.forRebirth.Value / 5.3, 0.066, 0.066), "Out", "Linear", 0.5)
end

updateAll()

player:WaitForChild("leaderstats").Damage.Changed:Connect(function()
	updateAll()
end)

So here I have a script that is local and it is in the gui, but the problem is that I want to, for example, if you have little power, this opoloska was just a short. That is smaller in coordinate X. Roughly I want it like this:

But for some reason the following happens when you enter the game:

P.S. This picture is just an example of what would happen if your current strength is half of what it should be. But if, for example, your current strength were close to the desired strength, then the yellow bar would almost fill the area. And this yellow bar is ImageLabel

UDim2.new() needs 4 arguments, not just 3. Also, your math was a bit off.

Fixed code:

local main = script.Parent
local player = game:GetService("Players").LocalPlayer

local function updateAll()
	main.progressBack.progressText.Text = player:WaitForChild("leaderstats").Damage.Value.. " / ".. main.forRebirth.Value
	main.progressBack.progressCurrent:TweenSize(
		UDim2.new(player:WaitForChild("leaderstats").Damage.Value / main.forRebirth.Value, 0, 1, 0),
		Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.5
	)
end

player:WaitForChild("leaderstats").Damage.Changed:Connect(updateAll)

updateAll()

If it doesn’t work, change the UDim2.new arguments that say 0 to match what your actual UI is.

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