How to End dialog after not being interacted with?

hello, i wanted to add a 10 second timer after everytime i interact mouse1click with this click detector, and after the 10 seconds the dialog resets, but also detecting if its been pressed again making the timer go back up to 10 and continuing the dialog.

this is what it looks like without any timer to end the dialog, the text will just stay like that untill interacted with again.

is it possible to make this ?
here is some code

--mousebutton1click on clickdetector
if module.thep.timer ~= 15 then
							module.thep.timer = 15
						else
							task.spawn(function()
								while task.wait(1) do
									module.thep.timer -= 1
									if module.thep.timer == 0 then
										-- code to end dialog
									end
								end
							end)
						end
						

i feel like this wouldent work , but i included this to show kinda alittle more of what im trying to do even know that this code is most definetly ineffective and doesnt work. for example how would i stop this spawn function from going when the player clicks it again?

im not well versed with task.delay but i feel as though this might be a solution?

any help will be greatly appriciated.