--// All global vars will be wiped/replaced except script


return function(data)
	local gui = script.Parent.Parent--client.UI.Prepare(script.Parent.Parent)
	local frame = gui.Frame
	local msg = frame.Message
	local ttl = frame.Title
	local ttlbg = frame.TitleBG
	local rmv = frame.ButtonRemove
	
	local gIndex = data.gIndex
	local gTable = data.gTable
	
	local title = data.Title
	local message = data.Message
	local scroll = data.Scroll
	local tim = data.Time
	
	local gone = false
	
	if not data.Message or not data.Title then gTable:Destroy() end
	
	ttl.Text = ""
	msg.Text = ""
	
	local function fadeIn()
		gTable:Ready()
		frame.Notify:Play()
		local Tween = game:GetService("TweenService"):Create(frame,TweenInfo.new(0.5,Enum.EasingStyle.Bounce,Enum.EasingDirection.Out),{Position=UDim2.new(0.5,0,0.5,-18)})
		Tween:Play()
		Tween.Completed:Wait()
		ttl.Text = title
		local Tween = game:GetService("TweenService"):Create(frame,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{Size=UDim2.new(0,350,0,150)})
		Tween:Play()
		Tween.Completed:Wait()
		game:GetService("TweenService"):Create(ttl,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{TextTransparency=0}):Play()
		game:GetService("TweenService"):Create(ttlbg,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency=0.5}):Play()
		local Tween = game:GetService("TweenService"):Create(msg,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{BackgroundTransparency=0.5})
		Tween:Play()
		Tween.Completed:Wait()
		for i = 1,#message,1 do
			msg.Text = message:sub(1,i)
			game:GetService("RunService").Heartbeat:wait()
		end
		wait(5)
		game:GetService("TweenService"):Create(rmv,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Position=UDim2.new(0.5,0,1,13)}):Play()
	end
	
	local function fadeOut()
		if not gone then
			gone = true
			local Tween = game:GetService("TweenService"):Create(rmv,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.In),{Position=UDim2.new(0.5,0,1,-100)})
			Tween:Play()
			Tween.Completed:Wait()
			rmv.Visible=false
		game:GetService("TweenService"):Create(ttl,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{TextTransparency=1}):Play()
		game:GetService("TweenService"):Create(ttlbg,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency=1}):Play()
			for i = #tostring(message),1,-1 do
				msg.Text = message:sub(1,i)
				game:GetService("RunService").Heartbeat:wait()
			end
			msg.Text = ""
			local Tween = game:GetService("TweenService"):Create(msg,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{BackgroundTransparency=1})
			Tween:Play()
			Tween.Completed:Wait()
			local Tween = game:GetService("TweenService"):Create(frame,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{Size=UDim2.new(0,64,0,64)})
			Tween:Play()
			Tween.Completed:Wait()
			local Tween = game:GetService("TweenService"):Create(frame,TweenInfo.new(0.5,Enum.EasingStyle.Bounce,Enum.EasingDirection.Out),{Position=UDim2.new(0.5,0,0,-100)})
			Tween:Play()
			Tween.Completed:Wait()
			service.UnWrap(gui):Destroy()
		end
	end
	
	gTable.CustomDestroy = function()
		fadeOut()
	end
	
	fadeIn()
	rmv.Visible=true
	rmv.MouseButton1Click:wait()
	if not gone then
		fadeOut()
	end
end
