return function(t)local F=service.PlayerGui local A=service.Players.LocalPlayer local W=script.Parent.Parent local Q=W.Frame local I=W.Frame.Close local h=W.Frame.Reply local g=W.Frame.Frame.ReplyBox local Y=W.Frame.Frame.Message local y=W.Frame.Title local m=t.Player local c=t.Message local R=t.Title local H=false local function L()if g.Text~="\069\110\116\101\114 \116\101\120\116 \116\104\101\110 \104\105\116 \101\110\116\101\114 \111\114 \"\114\101\112\108\121\""and#g.Text>0 then W:Destroy()client.Remote.Send("\080\114\105\118\097\116\101\077\101\115\115\097\103\101","\082\101\112\108\121 \102\114\111\109 "..A.Name,m,A,service.Filter(g.Text,A,m))client.UI.Make("\072\105\110\116",{Message="\082\101\112\108\121 \115\101\110\116"})else g.Text="\069\110\116\101\114 \116\101\120\116 \116\104\101\110 \104\105\116 \101\110\116\101\114 \111\114 \"\114\101\112\108\121\""end end Q.Visible=false g.Visible=true h.Visible=true Y.Text=c y.Text=R g.FocusLost:connect(function(t)if t then L()end end)I.MouseButton1Click:connect(function()W:Destroy()end)h.MouseButton1Click:connect(function()if not H then H=true Q:TweenSize(UDim2.new(0,300,0,280),nil,nil,.5)g:CaptureFocus()else L()end end)client.UI.Make("\078\111\116\105\102\105\099\097\116\105\111\110",{Title="\078\101\119 \077\101\115\115\097\103\101",Message="\078\101\119 \077\101\115\115\097\103\101 \102\114\111\109 "..(m.Name.."\046 \067\108\105\099\107 \116\111 \104\101\114\101 \116\111 \118\105\101\119\046");Time=false,OnClick=function()gTable:Ready()Q.Visible=true end;OnClose=function()gTable:Destroy()end,OnIgnore=function()gTable:Destroy()end})end


return function(data)
	local playergui = service.PlayerGui
	local localplayer = service.Players.LocalPlayer
	local gui = script.Parent.Parent
	local Frame = gui.Frame
	local Close = gui.Frame.Close
	local Reply = gui.Frame.Reply
	local ReplyBox = gui.Frame.Frame.ReplyBox
	local Message = gui.Frame.Frame.Message
	local Title = gui.Frame.Title
	
	local player = data.Player
	local message = data.Message
	local title = data.Title
	
	local replying = false
	
	local function send()
		if ReplyBox.Text~='Enter text then hit enter or "reply"' and #ReplyBox.Text>0 then 
			gui:Destroy()
			client.Remote.Send('PrivateMessage','Reply from '..localplayer.Name,player,localplayer,service.Filter(ReplyBox.Text,localplayer,player))
			client.UI.Make("Hint", {Message = "Reply sent"})
		else
			ReplyBox.Text='Enter text then hit enter or "reply"'
		end
	end
	
	Frame.Visible = false
	
	ReplyBox.Visible = true
	Reply.Visible = true
	
	Message.Text = message
	Title.Text = title
	
	ReplyBox.FocusLost:connect(function(enterPressed)
		if enterPressed then
			send()
		end
	end)
	
	Close.MouseButton1Click:connect(function() 
		gui:Destroy() 
	end)
	
	Reply.MouseButton1Click:connect(function()
		if not replying then
			replying = true
			Frame:TweenSize(UDim2.new(0,300,0,280),nil,nil,0.5)
			ReplyBox:CaptureFocus()
		else
			send()
		end
	end)
	
	client.UI.Make("Notification",{
		Title = "New Message";
		Message = "New Message from "..player.Name..". Click to here to view.";
		Time = false;
		OnClick = function() gTable:Ready() Frame.Visible = true end;
		OnClose = function() gTable:Destroy() end;
		OnIgnore = function() gTable:Destroy() end;
	})
end
