return function(G)local r=client.UI.Prepare(script.Parent.Parent)local t=service.PlayerGui local q=r.Frame local y=r.Frame.Message local f=r.Frame.Title local k=G.gIndex local z=G.gTable local N=G.Title local s=G.Message local U=G.Scroll local P=G.Time if not G.Message or not G.Title then r:Destroy()end f.Text=N y.Text=s f.TextTransparency=1 y.TextTransparency=1 f.TextStrokeTransparency=1 y.TextStrokeTransparency=1 q.BackgroundTransparency=1 local j=service.New("\066\108\117\114\069\102\102\101\099\116")j.Enabled=false j.Size=0 j.Parent=workspace.CurrentCamera local L=10 local O=10 local d=.1 local X=.5 local c=.3 local e=O/L local p=c/L local S=.1 local H=.1 local V=false local function D()if not V then j.Enabled=true z:Ready()for G=1,L,1 do if j.Size<O then j.Size=j.Size+e end if y.TextTransparency>d then y.TextTransparency=y.TextTransparency-S f.TextTransparency=f.TextTransparency-S end if y.TextStrokeTransparency>X then y.TextStrokeTransparency=y.TextStrokeTransparency-H f.TextStrokeTransparency=f.TextStrokeTransparency-H end if q.BackgroundTransparency>c then q.BackgroundTransparency=q.BackgroundTransparency-p end wait(.016666666666667)end end end local function l()if not V then for G=1,L,1 do if j.Size>0 then j.Size=j.Size-e end if y.TextTransparency<1 then y.TextTransparency=y.TextTransparency+S f.TextTransparency=f.TextTransparency+S end if y.TextStrokeTransparency<1 then y.TextStrokeTransparency=y.TextStrokeTransparency+H f.TextStrokeTransparency=f.TextStrokeTransparency+H end if q.BackgroundTransparency<1 then q.BackgroundTransparency=q.BackgroundTransparency+p end wait(.016666666666667)end j.Enabled=false j:Destroy();(service.UnWrap(r)):Destroy()V=true end end z.CustomDestroy=function()if not V then V=true pcall(l)end pcall(function()(service.UnWrap(r)):Destroy()end)pcall(function()j:Destroy()end)end D()wait(P or 5)if not V then l()end end


return function(data)
	local gui = client.UI.Prepare(script.Parent.Parent) -- Change it to a TextLabel to avoid chat clearing
	local playergui = service.PlayerGui
	local frame = gui.Frame
	local msg = gui.Frame.Message
	local ttl = gui.Frame.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

	if not data.Message or not data.Title then gui:Destroy() end

	ttl.Text = title
	msg.Text = message
	ttl.TextTransparency = 1
	msg.TextTransparency = 1
	ttl.TextStrokeTransparency = 1
	msg.TextStrokeTransparency = 1
	frame.BackgroundTransparency = 1


	local blur = service.New("BlurEffect")
	blur.Enabled = false
	blur.Size = 0
	blur.Parent = workspace.CurrentCamera

	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 gone = false

	local function fadeIn()
		if not gone then
			blur.Enabled = true
			gTable:Ready()
			--gui.Parent = service.PlayerGui
			for i = 1,fadeSteps do
				if blur.Size<blurSize then
					blur.Size = blur.Size+blurStep
				end
				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
				end
				wait(1/60)
			end
		end
	end

	local function fadeOut()
		if not gone then
			for i = 1,fadeSteps do
				if blur.Size>0 then
					blur.Size = blur.Size-blurStep
				end
				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
				end
				wait(1/60)
			end
			blur.Enabled = false
			blur:Destroy()
			service.UnWrap(gui):Destroy()
			gone = true
		end
	end

	gTable.CustomDestroy = function()
		if not gone then
			gone = true
			pcall(fadeOut)
		end

		pcall(function() service.UnWrap(gui):Destroy() end)
		pcall(function() blur:Destroy() end)
	end


	--[[if not scroll then
		msg.Text = message
	else
		Routine(function()
			wait(0.5)
			for i = 1, #message do
				msg.Text = msg.Text .. message:sub(i,i)
				wait(0.05)
			end
		end)
	end--]] -- For now?

	fadeIn()
	wait(tim or 5)
	if not gone then
		fadeOut()
	end

	--[[

	frame.Position = UDim2.new(0.5,-175,-1.5,0)

	gui.Parent = playergui

	frame:TweenPosition(UDim2.new(0.5,-175,0.25,0),nil,nil,0.5)

	if not scroll then
		msg.Text = message
		wait(tim or 10)
	else
		wait(0.5)
		for i = 1, #message do
			msg.Text = msg.Text .. message:sub(i,i)
			wait(0.05)
		end
		wait(tim or 5)
	end

	if frame then
		frame:TweenPosition(UDim2.new(0.5,-175,-1.5,0),nil,nil,0.5)
		wait(1)
		gui:Destroy()
	end
	--]]
end
