Hello while making a script I noticed a problem. Basically my problem is when a user clicks a button and leaves the code inside the button breaks at a certain point. Then I noticed I had an error that only happened when a user clicked the button and left. Here is the code:
ClickButton = game.Workspace.Button
ExitPart = game.Workspace.EXITPART
local Active = true
local Players = game:GetService(“Players”)
local Outcomes = { “Obby1”, “Obby2”, “Obby3”, “Obby4”, “Obby5”, “Obby6”, “Obby7”, “Obby8”, “Obby9”, “Obby10”, “Obby11”, “Obby12”}
ClickButton.ClickDetector.MouseClick:Connect(function(player)
local GUI = player:FindFirstChild(“PlayerGui”)
local Timer = GUI:FindFirstChild(“TimerGUI”)
--if on
if Active == true then
print("Button on")
local Obby = game:GetService("ServerStorage")[Outcomes[math.random(1, #Outcomes)]]:Clone()
Obby.Parent = workspace
Active = false
-------------timer--------------------------------------------------------------------------------
local timer = game.ReplicatedStorage.Timer
local lengthTime = 51
repeat
for i = lengthTime, 0, -1 do
timer.Value = i
wait(1)
end
until timer.Value == 0
--TIMER RUNS OUT
Obby:Destroy()
---Error here
Timer.TimerText.Text = "Game ended"
ExitPart.CanCollide = false
wait(3)
Timer.TimerText.Text = ""
ExitPart.CanCollide = true
Active = true
end
–If button is off
if Active == false then
print(“Button off”)
end
end)
Extra INFO: 
Error picture:
Sincerely, DevBattery
Thank you for your time
NO BLOCK CODE AND NO TYPOS

