return function(Y,s)if s then setfenv(1,s)end local Z=script.Parent.Parent local x=Z.Frame local b=x.Frame local J=b.Message local S=b.Title local c=Y.gIndex local O=Y.gTable local Q=Y.Title local d=Y.Message local p=Y.Scroll local f=Y.Time local L=false if not Y.Message or not Y.Title then O:Destroy()end S.Text=Q J.Text=d S.TextTransparency=1 J.TextTransparency=1 S.TextStrokeTransparency=1 J.TextStrokeTransparency=1 x.BackgroundTransparency=1 local E={Type="\083\109\097\108\108 \083\099\114\101\101\110 \077\101\115\115\097\103\101",Title=Q;Message=d,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,E)service.Events.CommsPanel:Fire(E)local m=10 local q=10 local N=.1 local k=.5 local U=.3 local K=q/m local o=U/m local H=.1 local X=.1 local function v()O:Ready()for Y=1,m,1 do if J.TextTransparency>N then J.TextTransparency=J.TextTransparency-H S.TextTransparency=S.TextTransparency-H end if J.TextStrokeTransparency>k then J.TextStrokeTransparency=J.TextStrokeTransparency-X S.TextStrokeTransparency=S.TextStrokeTransparency-X end if x.BackgroundTransparency>U then x.BackgroundTransparency=x.BackgroundTransparency-o b.BackgroundTransparency=x.BackgroundTransparency end service.Wait("\083\116\101\112\112\101\100")end end local function G()if not L then L=true for Y=1,m,1 do if J.TextTransparency<1 then J.TextTransparency=J.TextTransparency+H S.TextTransparency=S.TextTransparency+H end if J.TextStrokeTransparency<1 then J.TextStrokeTransparency=J.TextStrokeTransparency+X S.TextStrokeTransparency=S.TextStrokeTransparency+X end if x.BackgroundTransparency<1 then x.BackgroundTransparency=x.BackgroundTransparency+o b.BackgroundTransparency=x.BackgroundTransparency end service.Wait("\083\116\101\112\112\101\100")end;(service.UnWrap(Z)):Destroy()end end O.CustomDestroy=function()G()end v()if not f then local Y,s=d:gsub(" ","")s=math.clamp(s/2,4,11)+1 wait(s)else wait(f)end if not L then G()end end


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
