Progress bar won't tween size

Hello! I’m trying to make a progress bar for various statistics. However, the tweening (sizing) itself doesn’t work. I printed the Progress variable and it returns 0 every time, even when the CurrentCoal value changes. Not sure why it does that, because it really shouldn’t be 0.

local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local plr = Players.LocalPlayer
local Values = plr:WaitForChild("Values")
local MaxCoal = 25
local CurrentCoal = Values:FindFirstChild("Coal")
local Progress = CurrentCoal.Value / MaxCoal
local Button = script.Parent
local StatusText = Button.Status

print(CurrentCoal.Value, Progress)
local tween = TweenService:Create(Button.ProgressBar, TweenInfo.new(0.2,Enum.EasingStyle.Linear,Enum.EasingDirection.Out), {Size = UDim2.new(Progress, 0, 1, 0)})
tween:Play()
StatusText.Text = CurrentCoal.Value.."/25 INVENTORY COAL"


CurrentCoal:GetPropertyChangedSignal("Value"):Connect(function()
	print(CurrentCoal.Value, Progress)
	tween:Play()
	StatusText.Text = CurrentCoal.Value.."/25 INVENTORY COAL"
end)
1 Like

The problem here is you are playing the same tween with the same goal (0) whenever the property changes. Try creating a brand new tween every time the property changes instead.

2 Likes

That is not the issue (didn’t help). As I said already, it must be something with the Progress value, as it returns 0 every time, even when the CurrentCoal value returns something else than 0 in the print.

1 Like

That is because your progress variable remains fixed with the same value you originally set it as. You’ll have to change the variable every time the CurrentCoal value is updated, and create a new tween with said value.

2 Likes

Thank you so much, it works fully now.

2 Likes

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