-- EASING FUNCTIONS --

local function quadIn(t,b,c,d) t=t/d; return c*t*t+b; end;
local function quadOut(t,b,c,d) t=t/d; return -c*t*(t-2)+b; end;
local function Quad(obj,val,ease,d)
	local t,f,con,nt,st,sd=tick()
	Tweens[obj]=t -- Set identifier
	st=obj.Size.Y.Scale -- Start Value
	sd=val-st -- Change in Value
	f=ease=='In' and quadIn or quadOut -- Choose between Out/In
	con = game:GetService'RunService'.RenderStepped:connect(function() nt=tick()-t
		if Tweens[obj]~=t then -- Check for override
			con:disconnect()
			return
		end
		local nv=math.max(.05,f(math.min(d,nt),st,sd,d)) -- New Value
		obj.Size = UDim2.new(0.1,-3,nv,0)
		obj.BackgroundColor3=Color3.new(.7,.3,1):lerp(Color3.new(.3,1,.7),nv/Height)
		if nt>d then -- Easing done?
			con:disconnect()
			if ease~='In' then
				Quad(obj,.05,'In',.3) -- Drop the bar
			end
		end
	end)
end
