client,service=nil,nil return function(z,y)if y then setfenv(1,y)end local C local v=z.Time local x local W=false local c=service.New("\083\111\117\110\100",{Volume=.25,Looped=false,SoundId="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\053\049\055\049\053\057\053\057"})local V=service.New("\083\111\117\110\100",{Volume=.25;Looped=false;SoundId="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\054\055\056\056\051\048\054\054"})local h=service.TextService:GetTextSize(v,100,Enum.Font.SourceSans,Vector2.new(math.huge,math.huge))if h.X<150 then h=Vector2.new(175,h.Y)end local m=client.UI.Make("\087\105\110\100\111\119",{Name="\067\111\117\110\116\100\111\119\110";Title="\067\111\117\110\116\100\111\119\110",Icon=client.MatIcons["\072\111\117\114\103\108\097\115\115 \102\117\108\108"];Size={h.X+40;h.Y+20},Position=UDim2.new(0,10,1,-(h.Y+30));OnClose=function()c:Stop()V:Stop()c:Destroy()V:Destroy()end})local L=m:Add("\084\101\120\116\076\097\098\101\108",{Text=v;BackgroundTransparency=1,TextScaled=true})local U=m:Add("\084\101\120\116\076\097\098\101\108",{Text="\048";TextXAlignment=Enum.TextXAlignment.Right,BackgroundTransparency=1,Size=UDim2.fromOffset(25,25),Position=UDim2.new(1,-30,1,-25)})local Y=m:AddTitleButton({Text="",OnClick=function()if W then c.Volume=.25 V.Volume=.25 x.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\054\051\056\053\053\049\054\057\054"W=false else c.Volume=0 V.Volume=0 x.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\054\051\056\053\056\052\054\055\053"W=true end end})x=Y:Add("\073\109\097\103\101\076\097\098\101\108",{Size=UDim2.new(1,0,1,0);Position=UDim2.new(0,0,0,0),ScaleType=Enum.ScaleType.Fit;Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\054\051\056\053\053\049\054\057\054",BackgroundTransparency=1})c.Parent=L V.Parent=L C=m.gTable C:Ready()local u=os.clock()local t=0 local f=0 for z=v,1,-1 do if not C.Active then break end c:Play()L.Text=z U.Text=v-z task.wait(1-f)t+=1 f=(os.clock()-u)-t end L.Text="\048"U.Text=v V:Play()for z=0,3,1 do V:Play()for z=1,0,-0.1 do L.TextTransparency=z task.wait(.05)end for z=0,1,.1 do L.TextTransparency=z task.wait(.05)end end m:Close()end
client, service = nil, nil

return function(data, env)
	if env then
		setfenv(1, env)
	end
	
	local gTable
	local tLimit = data.Time
	local sImg

	local isMuted = false

	local tock = service.New("Sound", {
		Volume = 0.25; Looped = false; SoundId = "rbxassetid://151715959";
	})
	local buzzer = service.New("Sound", {
		Volume = 0.25; Looped = false; SoundId = "rbxassetid://267883066";
	})

	local textSize = service.TextService:GetTextSize(tLimit, 100, Enum.Font.SourceSans, Vector2.new(math.huge,math.huge))	
	if textSize.X < 150 then textSize = Vector2.new(175, textSize.Y) end

	local window = client.UI.Make("Window", {
		Name = "Countdown";
		Title = "Countdown";
		Icon = client.MatIcons["Hourglass full"];
		Size = {textSize.X + 40, textSize.Y + 20};
		Position = UDim2.new(0, 10, 1, -(textSize.Y + 30));
		OnClose = function()
			tock:Stop()
			buzzer:Stop()
			tock:Destroy()
			buzzer:Destroy()
		end
	})

	local label = window:Add("TextLabel", {
		Text = tLimit;
		BackgroundTransparency = 1;
		TextScaled = true;
	})

	local elapsed = window:Add("TextLabel", {
		Text = "0";
		TextXAlignment = Enum.TextXAlignment.Right;
		BackgroundTransparency = 1;
		Size = UDim2.fromOffset(25, 25);
		Position = UDim2.new(1, -30, 1, -25);
	})

	local muteButton = window:AddTitleButton({
		Text = "";
		OnClick = function()
			if isMuted then
				tock.Volume = 0.25
				buzzer.Volume = 0.25
				sImg.Image = "rbxassetid://1638551696"
				isMuted = false
			else
				tock.Volume = 0
				buzzer.Volume = 0
				sImg.Image = "rbxassetid://1638584675"
				isMuted = true
			end
		end
	})

	sImg = muteButton:Add("ImageLabel", {
		Size = UDim2.new(1,0,1,0);
		Position = UDim2.new(0,0,0,0);
		ScaleType = Enum.ScaleType.Fit;
		Image = "rbxassetid://1638551696";
		BackgroundTransparency = 1;
	})

	tock.Parent = label
	buzzer.Parent = label
	gTable = window.gTable
	gTable:Ready()

	local startTime = os.clock()
	local expectedDelay = 0
	local timeOff = 0

	for i = tLimit, 1, -1 do
		if not gTable.Active then break end
		tock:Play()
		label.Text = i
		elapsed.Text = tLimit - i
		task.wait(1 - timeOff)
		expectedDelay += 1
		timeOff = os.clock() - startTime - expectedDelay
	end

	label.Text = "0"
	elapsed.Text = tLimit

	buzzer:Play()

	for k = 0, 3 do
		buzzer:Play()
		for i = 1, 0, -0.1 do
			label.TextTransparency = i
			task.wait(0.05)
		end

		for i = 0, 1, 0.1 do
			label.TextTransparency = i
			task.wait(0.05)
		end
	end

	window:Close()
end
