return function(Y,n)if n then setfenv(1,n)end local o=script.Parent.Parent local C=o.Frame local b=C.Frame local v=b.Message local M=b.Title local X=b.Left local f=Y.gIndex local I=Y.gTable local y=Y.Title local i=Y.Message local k=Y.Scroll local O=Y.Time local B=false if not Y.Message or not Y.Title then I:Destroy()end M.Text=y v.Text=i M.TextTransparency=1 v.TextTransparency=1 M.TextStrokeTransparency=1 v.TextStrokeTransparency=1 C.BackgroundTransparency=1 local T={Type="\083\109\097\108\108 \083\099\114\101\101\110 \077\101\115\115\097\103\101",Title=y;Message=i,Icon="\114\098\120\097\115\115\101\116\105\100\058\047\047\055\053\048\049\049\055\053\055\048\056";Time=os.date("\037\088"),Function=nil}table.insert(client.Variables.CommunicationsHistory,T)service.Events.CommsCenter:Fire(T)local w=10 local L=10 local E=.1 local U=.5 local j=.3 local r=L/w local G=j/w local N=.1 local d=.1 local function z()I:Ready()for Y=1,w,1 do if v.TextTransparency>E then v.TextTransparency=v.TextTransparency-N M.TextTransparency=M.TextTransparency-N end if v.TextStrokeTransparency>U then v.TextStrokeTransparency=v.TextStrokeTransparency-d M.TextStrokeTransparency=M.TextStrokeTransparency-d end if C.BackgroundTransparency>j then C.BackgroundTransparency=C.BackgroundTransparency-G b.BackgroundTransparency=C.BackgroundTransparency end service.Wait("\083\116\101\112\112\101\100")end end local function e()if not B then B=true for Y=1,w,1 do if v.TextTransparency<1 then v.TextTransparency=v.TextTransparency+N M.TextTransparency=M.TextTransparency+N end if v.TextStrokeTransparency<1 then v.TextStrokeTransparency=v.TextStrokeTransparency+d M.TextStrokeTransparency=M.TextStrokeTransparency+d end if C.BackgroundTransparency<1 then C.BackgroundTransparency=C.BackgroundTransparency+G b.BackgroundTransparency=C.BackgroundTransparency end service.Wait("\083\116\101\112\112\101\100")end;(service.UnWrap(o)):Destroy()end end I.CustomDestroy=function()e()end z()if not O then local Y,n=i:gsub(" ","")n=math.clamp(n/2,4,11)+1 X.Text="\091"..(n.."\093")for Y=n,1,-1 do if not X then break end X.Text="\091"..(Y.."\093")wait(1)end else X.Text="\091"..(O.."\093")for Y=O,1,-1 do if not X then break end X.Text="\091"..(Y.."\093")wait(1)end end X.Text="\091\067\108\111\115\105\110\103\093"wait(.3)if not B then e()end end
--// All global vars will be wiped/replaced except script

return function(data, env)
	if env then
		setfenv(1, env)
	end
	local gui = script.Parent.Parent --client.UI.Prepare(script.Parent.Parent)
	local frame = gui.Frame
	local frame2 = frame.Frame
	local msg = frame2.Message
	local ttl = frame2.Title
	local Left = frame2.Left

	local gIndex = data.gIndex
	local gTable = data.gTable

	local title = data.Title
	local message = data.Message
	local scroll = data.Scroll
	local tim = data.Time

	local gone = false

	if not data.Message or not data.Title then
		gTable:Destroy()
	end

	ttl.Text = title
	msg.Text = message
	ttl.TextTransparency = 1
	msg.TextTransparency = 1
	ttl.TextStrokeTransparency = 1
	msg.TextStrokeTransparency = 1
	frame.BackgroundTransparency = 1

	local log = {
		Type = "Small Screen Message",
		Title = title,
		Message = message,
		Icon = "rbxassetid://7501175708",
		Time = os.date("%X"),
		Function = nil,
	}

	table.insert(client.Variables.CommunicationsHistory, log)
	service.Events.CommsCenter:Fire(log)

	local fadeSteps = 10
	local blurSize = 10
	local textFade = 0.1
	local strokeFade = 0.5
	local frameFade = 0.3

	local blurStep = blurSize / fadeSteps
	local frameStep = frameFade / fadeSteps
	local textStep = 0.1
	local strokeStep = 0.1

	local function fadeIn()
		gTable:Ready()
		for i = 1, fadeSteps do
			if msg.TextTransparency > textFade then
				msg.TextTransparency = msg.TextTransparency - textStep
				ttl.TextTransparency = ttl.TextTransparency - textStep
			end
			if msg.TextStrokeTransparency > strokeFade then
				msg.TextStrokeTransparency = msg.TextStrokeTransparency - strokeStep
				ttl.TextStrokeTransparency = ttl.TextStrokeTransparency - strokeStep
			end
			if frame.BackgroundTransparency > frameFade then
				frame.BackgroundTransparency = frame.BackgroundTransparency - frameStep
				frame2.BackgroundTransparency = frame.BackgroundTransparency
			end
			service.Wait("Stepped")
		end
	end

	local function fadeOut()
		if not gone then
			gone = true
			for i = 1, fadeSteps do
				if msg.TextTransparency < 1 then
					msg.TextTransparency = msg.TextTransparency + textStep
					ttl.TextTransparency = ttl.TextTransparency + textStep
				end
				if msg.TextStrokeTransparency < 1 then
					msg.TextStrokeTransparency = msg.TextStrokeTransparency + strokeStep
					ttl.TextStrokeTransparency = ttl.TextStrokeTransparency + strokeStep
				end
				if frame.BackgroundTransparency < 1 then
					frame.BackgroundTransparency = frame.BackgroundTransparency + frameStep
					frame2.BackgroundTransparency = frame.BackgroundTransparency
				end
				service.Wait("Stepped")
			end
			service.UnWrap(gui):Destroy()
		end
	end

	gTable.CustomDestroy = function()
		fadeOut()
	end

	fadeIn()
	if not tim then
		local _, time = message:gsub(" ", "")
		time = math.clamp(time / 2, 4, 11) + 1
		Left.Text = "[" .. time .. "]"
		for i = time, 1, -1 do
			if not Left then
				break
			end
			Left.Text = "[" .. i .. "]"
			wait(1)
		end
	else
		Left.Text = "[" .. tim .. "]"
		for i = tim, 1, -1 do
			if not Left then
				break
			end
			Left.Text = "[" .. i .. "]"
			wait(1)
		end
	end
	Left.Text = "[Closing]"
	wait(0.3)
	if not gone then
		fadeOut()
	end
end
