local function I(I,T,N,l)if I>=l then return T+N end return(N*I)/l+T end local function T(I,T,N,l)if I>=l then return T+N end I=I/l return T-(N*I)*(I-2)end local function N(I,T,N,l)if I>=l then return T+N end I=I/l if I<.5 then return((2*N)*I)*I+T end return T+N*((2*(2-I))*I-1)end function PropertyTweener(I,T,N,l,x,w,t)local o={}o.StartTime=tick()o.EndTime=o.StartTime+x o.Cancelled=false local c=false local J=0 local function E()if I then I[T]=w(1,N,l-N,1)end c=true J=1 if t then t()end end I[T]=w(0,N,l-N,x);(coroutine.wrap(function()local t=tick()while t<o.EndTime and I do if o.Cancelled then return end I[T]=w(t-o.StartTime,N,l-N,x)J=clamp(0,1,(t-o.StartTime)/x)RunService.RenderStepped:wait()t=tick()end if o.Cancelled==false and I then E()end end))()function o.GetFinal(I)return l end function o.GetPercentComplete(I)return J end function o.IsFinished(I)return c end function o.Finish(I)if not c then I:Cancel()E()end end function o.Cancel(I)o.Cancelled=true end return o end
---- TWEENZ ----
local function Linear(t, b, c, d)
	if t >= d then
		return b + c
	end

	return c * t / d + b
end

local function EaseOutQuad(t, b, c, d)
	if t >= d then
		return b + c
	end

	t = t / d
	return b - c * t * (t - 2)
end

local function EaseInOutQuad(t, b, c, d)
	if t >= d then
		return b + c
	end

	t = t / d
	if t < 1 / 2 then
		return 2 * c * t * t + b
	end
	return b + c * (2 * (2 - t) * t - 1)
end

function PropertyTweener(instance, prop, start, final, duration, easingFunc, cbFunc)
	local this = {}
	this.StartTime = tick()
	this.EndTime = this.StartTime + duration
	this.Cancelled = false

	local finished = false
	local percentComplete = 0

	local function finalize()
		if instance then
			instance[prop] = easingFunc(1, start, final - start, 1)
		end
		finished = true
		percentComplete = 1
		if cbFunc then
			cbFunc()
		end
	end

	-- Initial set
	instance[prop] = easingFunc(0, start, final - start, duration)
	coroutine.wrap(function()
		local now = tick()
		while now < this.EndTime and instance do
			if this.Cancelled then
				return
			end
			instance[prop] = easingFunc(now - this.StartTime, start, final - start, duration)
			percentComplete = clamp(0, 1, (now - this.StartTime) / duration)
			RunService.RenderStepped:wait()
			now = tick()
		end
		if this.Cancelled == false and instance then
			finalize()
		end
	end)()

	function this:GetFinal()
		return final
	end

	function this:GetPercentComplete()
		return percentComplete
	end

	function this:IsFinished()
		return finished
	end

	function this:Finish()
		if not finished then
			self:Cancel()
			finalize()
		end
	end

	function this:Cancel()
		this.Cancelled = true
	end

	return this
end
