local function Y(Y)for Y,u in pairs(currentNotices)do if not u.Complete.Value then local d=tweenInfoUp local R if Y==1 then R=template.Position+UDim2.new(0,-u.Size.X.Offset,0,0)else local d=currentNotices[Y-1]R=UDim2.new(u.Position.X.Scale,u.Position.X.Offset,u.Position.Y.Scale,template.Position.Y.Offset-(Y-1)*(template.Size.Y.Offset+5))end if R.Y.Offset>u.Position.Y.Offset then d=tweenInfoDown end if R then(main.tweenService:Create(u,d,{Position=R})):Play()end end end end local function u(u)if u:FindFirstChild("\067\111\109\112\108\101\116\101")and not u.Complete.Value then u.Complete.Value=true for Y,d in pairs(currentNotices)do if d==u then table.remove(currentNotices,Y)local d=main.tweenService:Create(u,tweenInfoEnd,{Position=u.Position+UDim2.new(0,u.Size.X.Offset-XOffset,0,0)})d:Play()d.Completed:Wait()u:Destroy()end end end Y()end local function d()if noticeDe then noticeDe=false repeat wait()if#noticeQueue>0 then local d=noticeQueue[1]d.Parent=notices if d.NoticeType.Value=="\069\114\114\111\114"then main.audio.Error:Play()else main.audio.Notice:Play()end table.insert(currentNotices,1,d)if d.Countdown.Value<900 then spawn(function()if d.Countdown.Value>0 then local Y=os.time()repeat wait()until os.time()~=Y local u=d.Desc.Text for Y=1,d.Countdown.Value,1 do if not d:FindFirstChild("\068\101\115\099")or d.Desc.Text=="\084\101\108\101\112\111\114\116\105\110\103\046\046\046"then break end d.Desc.Text=u..(" \040"..((d.Countdown.Value+1)-Y.."\041"))wait(1)end else local Y=tick()repeat wait(.1)until tick()-Y>=maxTime end u(d)end)end Y(true)wait(waitTime)table.remove(noticeQueue,1)end until#noticeQueue<1 noticeDe=true end end

local function updateNotices(newNotice)
	for i,notice in pairs(currentNotices) do
		if not notice.Complete.Value then
			local tweenInfo = tweenInfoUp
			local destination
			if i == 1 then
				destination = template.Position + UDim2.new(0,-notice.Size.X.Offset,0,0)
			else
				local noticeBefore = currentNotices[i-1]
				destination = UDim2.new(notice.Position.X.Scale, notice.Position.X.Offset, notice.Position.Y.Scale, template.Position.Y.Offset-((i-1)*(template.Size.Y.Offset+5)))
			end
			if destination.Y.Offset > notice.Position.Y.Offset then
				tweenInfo = tweenInfoDown
			end
			if destination then
				main.tweenService:Create(notice, tweenInfo, {Position = destination}):Play()
			end
		end
	end
end

local function endNotice(notice)
	if notice:FindFirstChild("Complete") and not notice.Complete.Value then
		notice.Complete.Value = true
		for i,v in pairs(currentNotices) do
			if v == notice then
				table.remove(currentNotices, i)
				local tween = main.tweenService:Create(notice, tweenInfoEnd, {Position = notice.Position + UDim2.new(0,(notice.Size.X.Offset-XOffset),0,0)})
				tween:Play()
				tween.Completed:Wait()
				notice:Destroy()
			end
		end
	end
	updateNotices()
end

local function Queue()
	if noticeDe then
		noticeDe = false
		repeat wait()
			if #noticeQueue > 0 then
				local notice = noticeQueue[1]
				notice.Parent = notices
				if notice.NoticeType.Value == "Error" then
					main.audio.Error:Play()
				else
					main.audio.Notice:Play()
				end
				table.insert(currentNotices, 1, notice)
				--
				if notice.Countdown.Value < 900 then
					spawn(function()
						if notice.Countdown.Value > 0 then
							local alignTime = os.time()
							repeat wait() until os.time() ~= alignTime
							local originalDesc = notice.Desc.Text
							for i = 1, notice.Countdown.Value do
								if not notice:FindFirstChild("Desc") or notice.Desc.Text == "Teleporting..." then
									break
								end
								notice.Desc.Text = originalDesc.." ("..notice.Countdown.Value+1-i..")"
								wait(1)
							end
						else
							local startTick = tick()
							repeat wait(0.1) until tick() - startTick >= maxTime
						end
						endNotice(notice)
					end)
				end
				--
				updateNotices(true)
				--
				wait(waitTime)
				table.remove(noticeQueue,1)
			end
		until #noticeQueue < 1
		noticeDe = true
	end
end

