How would I make a progress bar respond to IntValues?

Hello there,

I am trying to make a timer-countdown, and it is going well until I look at the progress bar. There are multiple factors that affect this bar and I’m unsure on how to solve it.

The Indicator is what get’s changed, so if it goes from 20 to 30. The timer-text will update but the bar won’t. I am a bit confused on how to update the bar.

  1. My progress bar is assuming that the TimeRate is 1 second and not 0.1 or 1.1. So it is a bit off.
  2. When I increase the time, the bar doesn’t update and it doesn’t want to shrink back to the start and that.

Here is my code for this:

local function DeathClock(TimeAmount, TimeRate)	
	local FrameNew = script.Timer:Clone()
	FrameNew.Parent = ContractUI

	local Indicator = Instance.new("IntValue", FrameNew)
	Indicator.Value = TimeAmount
	Indicator.Name = "Indicator"

	local TimerLabel = FrameNew:WaitForChild("TimerLabel")
	local Icon = FrameNew:WaitForChild("Icon")
	local Bar = FrameNew:WaitForChild("Bar")

	local TextBopProperties = {Position = UDim2.new(0,0,-1.35,0),TextColor3 = Color3.fromRGB(255,0,0)}
	local TimeBop = TweenService:Create(TimerLabel, TimerTick, TextBopProperties)

	TweenService:Create(FrameNew, TimerIntro, {Position = UDim2.new(0.3, 0, 0.85, 0)}):Play()
	
	ContractMusic:Play();TweenService:Create(ContractMusic, Info, {Volume = 0.75}):Play()

	script.Laugh:Play()
	task.wait(0.5)
	script.EquippedSound:Play()

	PlayerUI.StageTransfer.Contain.Blocker.Visible = true
	PlayerUI.StageTransfer.Contain.CurrentStage.Text = "0"

	task.spawn(function()
		repeat task.wait(TimeRate)
			
			if FrameNew == nil then return end
			
			if Defused == true then
				local LT = TweenService:Create(FrameNew, TimerIntro, {Position = UDim2.new(0.3, 0, 1.85, 0)})
				LT:Play()
				LT.Completed:Wait()
				break
			end
			
			Indicator.Value -= 1

			script.Tick:Play()
			TimerLabel.Text = FormatTime(Indicator.Value)
			TimeBop:Play()
			
		until Indicator.Value == 0
	end)

	Indicator:GetPropertyChangedSignal("Value"):Connect(function()			
		if Indicator == FormatTime(TimeAmount / 2) then
			Icon.Image = "rbxassetid://14520161480"
		elseif Indicator == 60 then
			Icon.Image = "rbxassetid://14520161286"
		elseif Indicator == 30 then
			Icon.Image = "rbxassetid://14520479224"
		end

		if Indicator == 0 then
			Icon.Visible = false
			script.Explosion:Play()
			Character:WaitForChild("Humanoid").Health = 0
			script.Explosion:Play()
		end
	end)

	Bar:TweenSize(UDim2.new(1, 0, 1, 0), Enum.EasingDirection.In, Enum.EasingStyle.Linear, TimeAmount)

	return FrameNew
end

You’re comparing the Indicator itself instead of Indicator.Value

I see. I’ll try this out, Sorry for the long delay by the way!

EDIT: This has nothing to do with the bar but was still fixed. May I get help on the main issue?