Issue with displaying a timer for a button

I am currently trying to create a button that when clicked will disable a wall for a set amount of time before the wall reappears. Currently due to the loop, the timer will display into the negatives and will never finish. But, if I don’t have the loop, then the timer will never go down. I want to do this without creating a long line of wait(1) then timerText = timerText - 1 and then Ttext.Text = timerText. Here is my current code for the button:

local timer = 10 --Input Time Given Here
local timerText = timer
local Ttext = script.Parent.BillboardGui.TGui

local deb = false
local button = script.Parent
local door = script.Parent.Parent.Door
local text1 = door.Texture1
local text2 = door.Texture2

local TweenService = game:GetService("TweenService")

local finishButton = {}
finishButton.Position = button.Position + Vector3.new(0,-0.5,0)
finishButton.Color = Color3.fromRGB(27, 42, 53)
local infoButton = TweenInfo.new(1, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out)
local buttonTween = TweenService:Create(button, infoButton, finishButton)

local infoDoor = TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
local doorTween = TweenService:Create(door, infoDoor, {Transparency = 1})

local T1Tween = TweenService:Create(text1, infoDoor, {Transparency = 1})
local T2Tween = TweenService:Create(text2, infoDoor, {Transparency = 1})

local finishButtonR = {}
finishButtonR.Position = button.Position + Vector3.new(0,0.5,0)
finishButtonR.Color = Color3.fromRGB(170, 85, 0)
local infoButtonR = TweenInfo.new(1, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out)
local buttonTweenR = TweenService:Create(button, infoButtonR, finishButtonR)

local infoDoorR = TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
local doorTweenR = TweenService:Create(door, infoDoorR, {Transparency = -2})

local T1TweenR = TweenService:Create(text1, infoDoorR, {Transparency = -2})
local T2TweenR = TweenService:Create(text2, infoDoorR, {Transparency = -2})

script.Parent.ClickDetector.MouseClick:Connect(function()
	if deb == false then
		deb = true
		buttonTween:Play()
		doorTween:Play()
		T1Tween:Play()
		T2Tween:Play()
		button.ClickDetector.MaxActivationDistance = 0
		button.Sound:Play()
		Ttext.Text = timer
		wait(0.5)
		door.CanCollide = false
		wait(0.5)
		button.PointLight.Range = 0
		while true do
			timerText = timerText - 1
			Ttext.Text = timerText
			task.wait(1)
		end
		wait(timer - 1)
		buttonTweenR:Play()
		doorTweenR:Play()
		T1TweenR:Play()
		T2TweenR:Play()
		Ttext = " "
		wait(0.5)
		door.CanCollide = true
		wait(0.5)
		button.ClickDetector.MaxActivationDistance = 5
		button.PointLight.Range = 20
		deb = false
	end
end)

I figured it out. It was a very simple fix. I just had to change the while true do loop to while timerText > 0.9 do loop.

You script seems messy, sorry if you need it to be that way but here is a more simpler version

local CD = script.Parent.ClickDetector
local Part = script.Parent.Parent.Test

local alreadyCanPass = false
local timeStayOpen = 3

local coutdownText = script.Parent.Parent.Coutdown.SurfaceGui.TextLabel

CD.MouseClick:Connect(function()
	if alreadyCanPass then return end

	alreadyCanPass = true
	
	Part.CanCollide = false
	Part.Transparency = 0.5
	
	for i = timeStayOpen, 0,-1 do
		coutdownText.Text = i
		task.wait(1)
	end
	
	Part.CanCollide = true
	Part.Transparency = 0
	alreadyCanPass = false
	coutdownText.Text = "Click the button"
end)

It does seem decently messy to me but I think that it is mostly from the tweens I added to make it look good.