client=nil service=nil return function(R,b)if b then setfenv(1,b)end local y local n=R.Time local u local k=false local H=service.New("\083\111\117\110\100")H.Volume=.25 H.Looped=false H.SoundId="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\049\053\049\055\049\053\057\053\057"local A=service.New("\083\111\117\110\100")A.Volume=.25 A.Looped=false A.SoundId="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\050\054\055\056\056\051\048\054\054"local Q=service.TextService:GetTextSize(n,100,Enum.Font.SourceSans,Vector2.new(math.huge,math.huge))if Q.X<150 then Q=Vector2.new(175,Q.Y)end local p=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",Size={Q.X+20;Q.Y+20};Position=UDim2.new(0,10,1,-(Q.Y+30)),OnClose=function()H:Stop()A:Stop()H:Destroy()A:Destroy()end})local e=p:Add("\084\101\120\116\076\097\098\101\108",{Text=n;BackgroundTransparency=1,TextScaled=true})local C=p:AddTitleButton({Text="";OnClick=function()if k then H.Volume=.25 A.Volume=.25 u.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\055\052\054\051\052\055\056\048\053\054"k=false else H.Volume=0 A.Volume=0 u.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\055\052\054\051\052\054\050\048\049\056"k=true end end})u=C:Add("\073\109\097\103\101\076\097\098\101\108",{Size=UDim2.new(1,0,.85,0),AnchorPoint=Vector2.new(.5,.5);ScaleType=Enum.ScaleType.Fit,Position=UDim2.new(.5,0,.536,0);Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\055\052\054\051\052\055\056\048\053\054";BackgroundTransparency=1})H.Parent=e A.Parent=e y=p.gTable y:Ready()local N=os.clock()local Y=0 local m=1 local G=0 for R=n,1,-1 do if y.Active then H:Play()e.Text=R else break end wait(m-G)Y+=m G=(os.clock()-N)-Y end e.Text="\048"A:Play()for R=0,3,1 do A:Play()for R=1,0,-0.1 do e.TextTransparency=R wait(.05)end for R=0,1,.1 do e.TextTransparency=R wait(.05)end end p:Close()end

client = nil
service = 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')
	tock.Volume = 0.25
	tock.Looped = false
	tock.SoundId = 'http://www.roblox.com/asset/?id=151715959'

	local buzzer = service.New('Sound')
	buzzer.Volume = 0.25
	buzzer.Looped = false
	buzzer.SoundId = 'http://www.roblox.com/asset/?id=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";
		Size = {textSize.X + 20, 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 muteButton = window:AddTitleButton({
		Text = "";
		OnClick = function()
			if isMuted then
				tock.Volume = 0.25
				buzzer.Volume = 0.25
				sImg.Image = "rbxassetid://7463478056"
				isMuted = false
			else
				tock.Volume = 0
				buzzer.Volume = 0
				sImg.Image = "rbxassetid://7463462018";
				isMuted = true
			end
		end
	})

	sImg = muteButton:Add("ImageLabel", {
		Size = UDim2.new(1, 0 ,0.85, 0);
		AnchorPoint = Vector2.new(0.5,0.5);
		ScaleType = Enum.ScaleType.Fit;
		Position = UDim2.new(0.5, 0 ,0.536, 0);
		Image = "rbxassetid://7463478056";
		BackgroundTransparency = 1;
	})

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

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

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

	label.Text = "0"

	buzzer:Play()

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

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

	window:Close()
end
