return function(O)local w=script.Parent.Parent local h=w.Frame local M=h.Frame local j=M.Message local i=M.Title local B=O.gIndex local C=O.gTable local X=O.Title local m=O.Message local e=O.Scroll local I=O.Time local r=false if not O.Message or not O.Title then C:Destroy()end i.Text=X j.Text=m i.TextTransparency=1 j.TextTransparency=1 i.TextStrokeTransparency=1 j.TextStrokeTransparency=1 h.BackgroundTransparency=1 local l={Type="\083\109\097\108\108 \083\099\114\101\101\110 \077\101\115\115\097\103\101",Title=X,Message=m;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,l)service.Events.CommsPanel:Fire(l)local J=10 local V=10 local c=.1 local H=.5 local k=.3 local Y=V/J local q=k/J local P=.1 local U=.1 local function W()C:Ready()for O=1,J,1 do if j.TextTransparency>c then j.TextTransparency=j.TextTransparency-P i.TextTransparency=i.TextTransparency-P end if j.TextStrokeTransparency>H then j.TextStrokeTransparency=j.TextStrokeTransparency-U i.TextStrokeTransparency=i.TextStrokeTransparency-U end if h.BackgroundTransparency>k then h.BackgroundTransparency=h.BackgroundTransparency-q M.BackgroundTransparency=h.BackgroundTransparency end service.Wait("\083\116\101\112\112\101\100")end end local function f()if not r then r=true for O=1,J,1 do if j.TextTransparency<1 then j.TextTransparency=j.TextTransparency+P i.TextTransparency=i.TextTransparency+P end if j.TextStrokeTransparency<1 then j.TextStrokeTransparency=j.TextStrokeTransparency+U i.TextStrokeTransparency=i.TextStrokeTransparency+U end if h.BackgroundTransparency<1 then h.BackgroundTransparency=h.BackgroundTransparency+q M.BackgroundTransparency=h.BackgroundTransparency end service.Wait("\083\116\101\112\112\101\100")end;(service.UnWrap(w)):Destroy()end end C.CustomDestroy=function()f()end W()if not I then local O,w=m:gsub(" ","")w=math.clamp(w/2,4,11)+1 wait(w)else wait(I)end if not r then f()end end


return function(data)
	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
