Telling when time is up and destroying button

Hi Guys,

How would I make it so when the time hits 0 I want the button to be destroyed?

Here is an image to show you what script I have used:

Capture

1 Like

I would suggest using repeat wait() until, and use a value to keep track of the time.

local textLabel = script.Parent.Parent.TextLabel
local timer = Instance.new('NumberValue')
timer.Name = 'Timer'
timer.Parent = textLabel
timer.Value = 20 -- The time

timer:GetPropertyChangedSignal('Value'):Connect(function()
    textLabel.Text = 'Timer: '..timer.Value
end)

repeat
	timer.Value -= 1
	wait(1)
until timer.Value == "0"

Also, a tip next time - instead of sending a screenshot of your script, format it correctly with the three backticks (```)