return function(P)local l=service.PlayerGui local r=service.Players.LocalPlayer local O=script.Parent.Parent local v=O.Frame local S=O.Frame.Close local z=O.Frame.Reply local x=O.Frame.Frame.ReplyBox local A=O.Frame.Frame.Message local U=O.Frame.Title local k=P.Player local B=P.Message local s=P.Title local R=false local function I()if x.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#x.Text>0 then O: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 "..r.Name,k,r,service.Filter(x.Text,r,k))client.UI.Make("\072\105\110\116",{Message="\082\101\112\108\121 \115\101\110\116"})else x.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 v.Visible=false x.Visible=true z.Visible=true A.Text=B U.Text=s x.FocusLost:connect(function(P)if P then I()end end)S.MouseButton1Click:connect(function()O:Destroy()end)z.MouseButton1Click:connect(function()if not R then R=true v:TweenSize(UDim2.new(0,300,0,280),nil,nil,.5)x:CaptureFocus()else I()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 "..(k.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()v.Visible=true end,OnClose=function()gTable:Destroy()end,OnIgnore=function()gTable:Destroy()end})end
--// All global vars will be wiped/replaced except script

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
