return function(p)local W,S=p.Title,p.Message if not W or not S then return end local a=p.gTable local w=script.Parent.Parent.BaseClip local U=w.Frame local X=U X.Size=UDim2.new(1,0,0,w.AbsoluteSize.Y)X.Position=UDim2.new(0,0,-1,0)X.Parent=w X.Visible=true local O=X:WaitForChild("\084\101\120\116\066\117\116\116\111\110")local I=X:WaitForChild("\084\111\112")local y=X:WaitForChild("\066\111\100\121")local e=I:WaitForChild("\084\105\116\108\101")local l=y:WaitForChild("\084\111 \078\097\109\101 \076\097\116\101\114")local D=I:WaitForChild("\076\101\102\116")e.Text=W l.Text=S local r=l.TextBounds.Y if r<30 then r=30 else r=r+15 end local N=I.Size.Y.Offset X.Size=UDim2.new(1,0,0,r+N)local function Q()local p local W,S=pcall(function()p=a.BindEvent(w.Changed,function(W)if W=="\065\098\115\111\108\117\116\101\083\105\122\101"then X.Size=UDim2.new(1,0,0,w.AbsoluteSize.Y)local W=l.TextBounds.Y if W<30 then W=30 else W=W+15 end local S=I.Size.Y.Offset X.Size=UDim2.new(1,0,0,W+S)if X~=nil and X.Parent==w then X:TweenPosition(UDim2.new(0,0,.5,-X.Size.Y.Offset/2),"\079\117\116","\081\117\105\110\116",.5,true)else if p then p:Disconnect()end return end end end)end)if S and p then p:Disconnect()return end end a.CustomDestroy=function()a.CustomDestroy=nil a.ClearEvents()pcall(function()X:TweenPosition(UDim2.new(0,0,1,0),"\079\117\116","\081\117\105\110\116",.3,true,function(p)if p==Enum.TweenStatus.Completed and X then X:Destroy()elseif p==Enum.TweenStatus.Canceled and X then X:Destroy()end end)wait(.3)end)return a.Destroy()end a:Ready()X:TweenPosition(UDim2.new(0,0,.5,-X.Size.Y.Offset/2),"\079\117\116","\081\117\105\110\116",.5,true,function(p)if p==Enum.TweenStatus.Completed then Q()end end)a.BindEvent(O.MouseButton1Click,function()pcall(function()X:TweenPosition(UDim2.new(0,0,1,0),"\079\117\116","\081\117\105\110\116",.3,true,function(p)if p==Enum.TweenStatus.Completed and X then X:Destroy()a:Destroy()elseif p==Enum.TweenStatus.Canceled and X then X:Destroy()a:Destroy()end end)end)end)local J=#l.Text*.1+1 local C,v=string.find(J,"\037\112")if C and v then local p=tonumber(string.sub(J,C))if p>=.5 then J=tonumber(string.sub(J,1,C))+1 else J=tonumber(string.sub(J,1,C))end end if J>15 then J=15 elseif J<=1 then J=2 end D.Text=J.."\046\048\048"for p=J,1,-1 do if not D then break end D.Text=p.."\046\048\048"wait(1)end D.Text="\067\108\111\115\105\110\103\046\046"wait(.3)if X then pcall(function()X:TweenPosition(UDim2.new(0,0,1,0),"\079\117\116","\081\117\105\110\116",.3,true,function(p)if p==Enum.TweenStatus.Completed and X then X:Destroy()a:Destroy()elseif p==Enum.TweenStatus.Canceled and X then X:Destroy()a:Destroy()end end)end)end end


return function(data)
	local Title,Message = data.Title,data.Message
	if not Title or not Message then return end
	
	local gTable = data.gTable
	local baseClip = script.Parent.Parent.BaseClip
	local messageTemplate = baseClip.Frame
	local messageClone = messageTemplate
	messageClone.Size = UDim2.new(1,0,0,baseClip.AbsoluteSize.Y)
	messageClone.Position = UDim2.new(0,0,-1,0)
	messageClone.Parent = baseClip
	messageClone.Visible = true
	local closeButton = messageClone:WaitForChild('TextButton')
	local Top = messageClone:WaitForChild('Top')
	local Body = messageClone:WaitForChild('Body')
	local topTitle = Top:WaitForChild('Title')
	local bodyText = Body:WaitForChild('To Name Later')
	local Left = Top:WaitForChild('Left')
	topTitle.Text = Title
	bodyText.Text = Message
	local bodyBounds_Y = bodyText.TextBounds.Y
	if bodyBounds_Y < 30 then
		bodyBounds_Y = 30
	else
		bodyBounds_Y = bodyBounds_Y + 15
	end
	local titleSize_Y = Top.Size.Y.Offset
	messageClone.Size = UDim2.new(1,0,0,bodyBounds_Y+titleSize_Y)
	
	local function Resize()
		local toDisconnect
		local Success, Message = pcall(function()
			toDisconnect = gTable.BindEvent(baseClip.Changed, function(Prop)
				if Prop == "AbsoluteSize" then
					messageClone.Size = UDim2.new(1,0,0,baseClip.AbsoluteSize.Y)
					local bodyBounds_Y = bodyText.TextBounds.Y
					if bodyBounds_Y < 30 then
						bodyBounds_Y = 30
					else
						bodyBounds_Y = bodyBounds_Y + 15
					end
					local titleSize_Y = Top.Size.Y.Offset
					messageClone.Size = UDim2.new(1,0,0,bodyBounds_Y+titleSize_Y)
					if (messageClone ~= nil and messageClone.Parent == baseClip) then
						messageClone:TweenPosition(UDim2.new(0,0,0.5,-messageClone.Size.Y.Offset/2),'Out','Quint',0.5,true)
					else
						if toDisconnect then
							toDisconnect:Disconnect()
						end
						return
					end
				end
			end)
		end)
		if Message and toDisconnect then
			toDisconnect:Disconnect()
			return
		end
	end
	
	gTable.CustomDestroy = function()
		gTable.CustomDestroy = nil
		gTable.ClearEvents()
		
		pcall(function()
			messageClone:TweenPosition(UDim2.new(0,0,1,0),'Out','Quint',0.3,true,function(Done)
				if Done == Enum.TweenStatus.Completed and messageClone then
					messageClone:Destroy()
				elseif Done == Enum.TweenStatus.Canceled and messageClone then
					messageClone:Destroy()
				end
			end)
			wait(0.3)
		end)
		
		return gTable.Destroy()
	end	
	
	gTable:Ready()
	messageClone:TweenPosition(UDim2.new(0,0,0.5,-messageClone.Size.Y.Offset/2),'Out','Quint',0.5,true,function(Status)
		if Status == Enum.TweenStatus.Completed then
			Resize()
		end
	end)
	
	gTable.BindEvent(closeButton.MouseButton1Click, function()
		pcall(function()
			messageClone:TweenPosition(UDim2.new(0,0,1,0),'Out','Quint',0.3,true,function(Done)
				if Done == Enum.TweenStatus.Completed and messageClone then
					messageClone:Destroy()
					gTable:Destroy()
				elseif Done == Enum.TweenStatus.Canceled and messageClone then
					messageClone:Destroy()
					gTable:Destroy()
				end
			end)
		end)
	end)
	
	local waitTime = (#bodyText.Text*0.1)+1
	local Position_1,Position_2 = string.find(waitTime,"%p")
	if Position_1 and Position_2 then
		local followingNumbers = tonumber(string.sub(waitTime,Position_1))
		if followingNumbers >= 0.5 then
			waitTime = tonumber(string.sub(waitTime,1,Position_1))+1
		else
			waitTime = tonumber(string.sub(waitTime,1,Position_1))
		end
	end
	if waitTime > 15 then
		waitTime = 15
	elseif waitTime <= 1 then
		waitTime = 2
	end
	Left.Text = waitTime..'.00'
	for i=waitTime,1,-1 do
		if not Left then break end
		Left.Text = i..'.00'
		wait(1)
	end
	Left.Text = "Closing.."
	wait(0.3)
	if messageClone then
		pcall(function()
			messageClone:TweenPosition(UDim2.new(0,0,1,0),'Out','Quint',0.3,true,function(Done)
				if Done == Enum.TweenStatus.Completed and messageClone then
					messageClone:Destroy()
					gTable:Destroy()
				elseif Done == Enum.TweenStatus.Canceled and messageClone then
					messageClone:Destroy()
					gTable:Destroy()
				end
			end)
		end)
	end
end
