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