client,service=nil,nil return function(z,y)if y then setfenv(1,y)end local C,v,x,W local c={}local function V(z,y,C,v,W,V)print(v)local h=x:Add("\070\114\097\109\101",{Size=UDim2.new(1,0,0,50),BackgroundTransparency=1,AutomaticSize="\089";Children={{ClassName="\070\114\097\109\101",Name="\076\111\103\103\101\100\073\116\101\109";Size=UDim2.new(1,-10,1,-10),Position=UDim2.new(0,5,0,5);BackgroundTransparency=.5;AutomaticSize="\089";Children={{ClassName="\073\109\097\103\101\066\117\116\116\111\110";Name="\073\099\111\110";Size=UDim2.new(0,48,0,48),Position=UDim2.new(0,1,0,1),Image=v;OnClick=V,BackgroundTransparency=1},{ClassName="\084\101\120\116\066\117\116\116\111\110",Name="\084\105\116\108\101",Size=UDim2.new(1,-55,0,15);Position=UDim2.new(0,55,0,0);Text=y,TextSize="\049\052";TextXAlignment="\076\101\102\116",BackgroundTransparency=1,OnClick=V};{ClassName="\084\101\120\116\066\117\116\116\111\110",Name="\084\121\112\101",Size=UDim2.new(1,-55,0,15),Position=UDim2.new(0,55,0,0),Text=z,TextSize="\049\052";TextXAlignment="\082\105\103\104\116",BackgroundTransparency=1,OnClick=V},{ClassName="\084\101\120\116\066\117\116\116\111\110";Name="\084\105\109\101";Size=UDim2.new(1,-55,0,15);Position=UDim2.new(0,55,0,15);Text=W,TextSize="\049\052",TextXAlignment="\082\105\103\104\116",BackgroundTransparency=1;OnClick=V},{ClassName="\084\101\120\116\066\117\116\116\111\110",Name="\070\117\110\099\116\105\111\110";Size=UDim2.new(1,-55,0,15);Position=UDim2.new(0,55,0,30);Text=V and"\067\108\105\099\107\097\098\108\101"or"\078\111\116 \099\108\105\099\107\097\098\108\101",TextSize="\049\052";TextXAlignment="\082\105\103\104\116";BackgroundTransparency=1;OnClick=V};{ClassName="\084\101\120\116\066\117\116\116\111\110";Name="\077\101\115\115\097\103\101",Size=UDim2.new(1,-55,0,10);Position=UDim2.new(0,55,0,15),Text=C;TextXAlignment="\076\101\102\116";TextYAlignment="\084\111\112";AutomaticSize="\089";TextWrapped=true,TextScaled=false,RichText=true;BackgroundTransparency=1;OnClick=V}}}}})table.insert(c,h)if#c>200 then c[1]:Destroy()table.remove(c,1)end end v=client.UI.Make("\087\105\110\100\111\119",{Name="\067\111\109\109\117\110\105\099\097\116\105\111\110\115\080\097\110\101\108";Title="\067\111\109\109\117\110\105\099\097\116\105\111\110\115 \080\097\110\101\108";Icon=client.MatIcons.Forum,Size={500;300};OnClose=function()client.Variables.CommsPanelBindableEvent=nil end})x=v:Add("\083\099\114\111\108\108\105\110\103\070\114\097\109\101",{Size=UDim2.new(1,0,1,0);Position=UDim2.new(0,0,0,0),CanvasSize=UDim2.new(0,0,0,0);BackgroundTransparency=.9})W=service.New("\085\073\076\105\115\116\076\097\121\111\117\116",{Parent=x,FillDirection="\086\101\114\116\105\099\097\108",HorizontalAlignment="\076\101\102\116",VerticalAlignment="\066\111\116\116\111\109";SortOrder="\076\097\121\111\117\116\079\114\100\101\114"});(W:GetPropertyChangedSignal("\065\098\115\111\108\117\116\101\067\111\110\116\101\110\116\083\105\122\101")):Connect(function()x.CanvasSize=UDim2.new(0,0,0,W.AbsoluteContentSize.Y)x.CanvasPosition=Vector2.new(0,W.AbsoluteContentSize.Y)end)if client.Variables.CommunicationsHistory then for z,y in ipairs(client.Variables.CommunicationsHistory)do V(y.Type,y.Title,y.Message,y.Icon,y.Time,y.Function)end end service.HookEvent("\067\111\109\109\115\080\097\110\101\108",function(z)V(z.Type,z.Title,z.Message,z.Icon,z.Time,z.Function)end)C=v.gTable v:Ready()end
client, service = nil, nil

return function(data, env)
	if env then
		setfenv(1, env)
	end
	
	local gTable, window, commslog, layout
	local messageObjs = {}

	local function newMessage(Type, Title, Message, Icon, Time, Function)
		print(Icon)

		local newMsg = commslog:Add("Frame", {
			Size = UDim2.new(1, 0, 0, 50);
			BackgroundTransparency = 1;
			AutomaticSize = "Y";
			Children = {
				{ClassName = "Frame";
					Name = "LoggedItem";
					Size = UDim2.new(1, -10, 1, -10);
					Position = UDim2.new(0, 5, 0, 5);
					BackgroundTransparency = 0.5;
					AutomaticSize = "Y";
					Children = {
						{ClassName = "ImageButton";
							Name = "Icon";
							Size = UDim2.new(0, 48, 0, 48);
							Position = UDim2.new(0, 1, 0, 1);
							Image = Icon;
							OnClick = Function;
							BackgroundTransparency = 1;
						};

						{ClassName = "TextButton";
							Name = "Title";
							Size = UDim2.new(1, -55, 0, 15);
							Position = UDim2.new(0, 55, 0, 0);
							Text = Title;
							TextSize = "14";
							TextXAlignment = "Left";
							BackgroundTransparency = 1;
							OnClick = Function;
						};
						
						{ClassName = "TextButton";
							Name = "Type";
							Size = UDim2.new(1, -55, 0, 15);
							Position = UDim2.new(0, 55, 0, 0);
							Text = Type;
							TextSize = "14";
							TextXAlignment = "Right";
							BackgroundTransparency = 1;
							OnClick = Function;
						};
						
						{ClassName = "TextButton";
							Name = "Time";
							Size = UDim2.new(1, -55, 0, 15);
							Position = UDim2.new(0, 55, 0, 15);
							Text = Time;
							TextSize = "14";
							TextXAlignment = "Right";
							BackgroundTransparency = 1;
							OnClick = Function;
						};
						
						{ClassName = "TextButton";
							Name = "Function";
							Size = UDim2.new(1, -55, 0, 15);
							Position = UDim2.new(0, 55, 0, 30);
							Text = Function and "Clickable" or "Not clickable";
							TextSize = "14";
							TextXAlignment = "Right";
							BackgroundTransparency = 1;
							OnClick = Function;
						};

						{ClassName = "TextButton";
							Name = "Message";
							Size = UDim2.new(1, -55, 0, 10);
							Position = UDim2.new(0, 55, 0, 15);
							Text = Message;
							TextXAlignment = "Left";
							TextYAlignment = "Top";
							AutomaticSize = "Y";
							TextWrapped = true;
							TextScaled = false;
							RichText = true;
							BackgroundTransparency = 1;
							OnClick = Function;
						};
					}
				}
			}
		})

		table.insert(messageObjs, newMsg)

		if #messageObjs > 200 then
			messageObjs[1]:Destroy()
			table.remove(messageObjs, 1)
		end
	end
	
	window = client.UI.Make("Window",{
		Name  = "CommunicationsPanel";
		Title = "Communications Panel";
		Icon = client.MatIcons.Forum;
		Size  = {500, 300};
		OnClose = function()
			client.Variables.CommsPanelBindableEvent = nil
		end;
	})

	commslog = window:Add("ScrollingFrame",{
		Size = UDim2.new(1, 0, 1, 0);
		Position = UDim2.new(0, 0, 0, 0);
		CanvasSize = UDim2.new(0, 0, 0, 0);
		BackgroundTransparency = 0.9;
	})

	layout = service.New("UIListLayout", {
		Parent = commslog;
		FillDirection = "Vertical";
		HorizontalAlignment = "Left";
		VerticalAlignment = "Bottom";
		SortOrder = "LayoutOrder";
	})

	layout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
		commslog.CanvasSize = UDim2.new(0, 0, 0, layout.AbsoluteContentSize.Y)
		commslog.CanvasPosition = Vector2.new(0, layout.AbsoluteContentSize.Y)
	end)

	if client.Variables.CommunicationsHistory then
		for i, v in ipairs(client.Variables.CommunicationsHistory) do
			newMessage(v.Type, v.Title, v.Message, v.Icon, v.Time, v.Function);
		end
	end
	
	service.HookEvent("CommsPanel", function(v)
		newMessage(v.Type, v.Title, v.Message, v.Icon, v.Time, v.Function)
	end)

	gTable = window.gTable
	window:Ready()
end
