return function(e,Q)if Q then setfenv(1,Q)end local L=script.Parent.Parent local Z=L.Frame local C=Z.Frame local d=C.Message local r=C.Title local q=e.gIndex local I=e.gTable local o=e.Title local J=e.Message local g=e.Scroll local t=e.Time local T=false if not e.Message or not e.Title then I:Destroy()end r.Text=o d.Text=J r.TextTransparency=1 d.TextTransparency=1 r.TextStrokeTransparency=1 d.TextStrokeTransparency=1 Z.BackgroundTransparency=1 local f={Type="\083\109\097\108\108 \083\099\114\101\101\110 \077\101\115\115\097\103\101",Title=o,Message=J;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,f)service.Events.CommsPanel:Fire(f)local W=10 local x=10 local G=.1 local c=.5 local m=.3 local V=x/W local l=m/W local O=.1 local U=.1 local function u()I:Ready()for e=1,W,1 do if d.TextTransparency>G then d.TextTransparency=d.TextTransparency-O r.TextTransparency=r.TextTransparency-O end if d.TextStrokeTransparency>c then d.TextStrokeTransparency=d.TextStrokeTransparency-U r.TextStrokeTransparency=r.TextStrokeTransparency-U end if Z.BackgroundTransparency>m then Z.BackgroundTransparency=Z.BackgroundTransparency-l C.BackgroundTransparency=Z.BackgroundTransparency end service.Wait("\083\116\101\112\112\101\100")end end local function N()if not T then T=true for e=1,W,1 do if d.TextTransparency<1 then d.TextTransparency=d.TextTransparency+O r.TextTransparency=r.TextTransparency+O end if d.TextStrokeTransparency<1 then d.TextStrokeTransparency=d.TextStrokeTransparency+U r.TextStrokeTransparency=r.TextStrokeTransparency+U end if Z.BackgroundTransparency<1 then Z.BackgroundTransparency=Z.BackgroundTransparency+l C.BackgroundTransparency=Z.BackgroundTransparency end service.Wait("\083\116\101\112\112\101\100")end;(service.UnWrap(L)):Destroy()end end I.CustomDestroy=function()N()end u()if not t then local e,Q=J:gsub(" ","")Q=math.clamp(Q/2,4,11)+1 wait(Q)else wait(t)end if not T then N()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 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.CommsPanel: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
		wait(time)
	else
		wait(tim)
	end
	if not gone then
		fadeOut()
	end
end
