local Q=0 spring={mt={}}spring.mt.__index=spring function spring.new(Q)local Y=tick()local G=Q or 0 local L=Q and 0*Q or 0 local H=Q or 0 local j=1 local i=1 local function s(Q)local s=Q-Y local q=G-H if i==0 then return G,0 elseif j<1 then local Q=(1-j*j)^.5 local Y=(L/i+j*q)/Q local G=math.cos((Q*i)*s)local d=math.sin((Q*i)*s)local E=2.718281828459^((j*i)*s)return H+(q*G+Y*d)/E,(i*((Q*Y-j*q)*G-(Q*q+j*Y)*d))/E else local Q=L/i+q local Y=2.718281828459^(i*s)return H+(q+(Q*i)*s)/Y,(i*((Q-q)-(Q*i)*s))/Y end end return setmetatable({},{__index=function(Q,q)if q=="\118\097\108\117\101"or q=="\112\111\115\105\116\105\111\110"or q=="\112"then local Q,Y=s(tick())return Q elseif q=="\118\101\108\111\099\105\116\121"or q=="\118"then local Q,Y=s(tick())return Y elseif q=="\097\099\099\101\108\101\114\097\116\105\111\110"or q=="\097"then local Q=tick()-Y local s=G-H if i==0 then return 0 elseif j<1 then local Y=(1-j*j)^.5 local G=(L/i+j*s)/Y return((i*i)*((((j*j)*s-((2*Y)*j)*G)-(Y*Y)*s)*math.cos((Y*i)*Q)+(((j*j)*G+((2*Y)*j)*s)-(Y*Y)*G)*math.sin((Y*i)*Q)))/2.718281828459^((j*i)*Q)else local Y=L/i+s return((i*i)*((s-2*Y)+(Y*i)*Q))/2.718281828459^(i*Q)end elseif q=="\116\097\114\103\101\116"or q=="\116"then return H elseif q=="\100\097\109\112\101\114"or q=="\100"then return j elseif q=="\115\112\101\101\100"or q=="\115"then return i end end;__newindex=function(Q,q,d)local E=tick()if q=="\118\097\108\117\101"or q=="\112\111\115\105\116\105\111\110"or q=="\112"then local Q,Y=s(E)G,L=d,Y elseif q=="\118\101\108\111\099\105\116\121"or q=="\118"then local Q,Y=s(E)G,L=Q,d elseif q=="\097\099\099\101\108\101\114\097\116\105\111\110"or q=="\097"then local Q,Y=s(E)G,L=Q,Y+d elseif q=="\116\097\114\103\101\116"or q=="\116"then G,L=s(E)H=d elseif q=="\100\097\109\112\101\114"or q=="\100"then G,L=s(E)j=d<0 and 0 or d<1 and d or 1 elseif q=="\115\112\101\101\100"or q=="\115"then G,L=s(E)i=d<0 and 0 or d end Y=E end})end return spring
--do -- springs, ok, totally not from treyreynolds
--local runtime = game ("GetService", "RunService")
local t = 0

spring = { mt = {} }
spring.mt.__index = spring

function spring.new(initial)
	local t0 = tick()
	local p0 = initial or 0
	local v0 = initial and 0 * initial or 0
	local t = initial or 0
	local d = 1
	local s = 1

	local function positionvelocity(tick)
		local x = tick - t0
		local c0 = p0 - t
		if s == 0 then
			return p0, 0
		elseif d < 1 then
			local c = (1 - d * d) ^ 0.5
			local c1 = (v0 / s + d * c0) / c
			local co = math.cos(c * s * x)
			local si = math.sin(c * s * x)
			local e = 2.718281828459045 ^ (d * s * x)
			return t + (c0 * co + c1 * si) / e, s * ((c * c1 - d * c0) * co - (c * c0 + d * c1) * si) / e
		else
			local c1 = v0 / s + c0
			local e = 2.718281828459045 ^ (s * x)
			return t + (c0 + c1 * s * x) / e, s * (c1 - c0 - c1 * s * x) / e
		end
	end
	return setmetatable({}, {
		__index = function(_, index)
			if index == "value" or index == "position" or index == "p" then
				local p, v = positionvelocity(tick())
				return p
			elseif index == "velocity" or index == "v" then
				local p, v = positionvelocity(tick())
				return v
			elseif index == "acceleration" or index == "a" then
				local x = tick() - t0
				local c0 = p0 - t
				if s == 0 then
					return 0
				elseif d < 1 then
					local c = (1 - d * d) ^ 0.5
					local c1 = (v0 / s + d * c0) / c
					return s
						* s
						* ((d * d * c0 - 2 * c * d * c1 - c * c * c0) * math.cos(c * s * x) + (d * d * c1 + 2 * c * d * c0 - c * c * c1) * math.sin(
							c * s * x
						))
						/ 2.718281828459045 ^ (d * s * x)
				else
					local c1 = v0 / s + c0
					return s * s * (c0 - 2 * c1 + c1 * s * x) / 2.718281828459045 ^ (s * x)
				end
			elseif index == "target" or index == "t" then
				return t
			elseif index == "damper" or index == "d" then
				return d
			elseif index == "speed" or index == "s" then
				return s
			end
		end,
		__newindex = function(_, index, value)
			local time = tick()
			if index == "value" or index == "position" or index == "p" then
				local p, v = positionvelocity(time)
				p0, v0 = value, v
			elseif index == "velocity" or index == "v" then
				local p, v = positionvelocity(time)
				p0, v0 = p, value
			elseif index == "acceleration" or index == "a" then
				local p, v = positionvelocity(time)
				p0, v0 = p, v + value
			elseif index == "target" or index == "t" then
				p0, v0 = positionvelocity(time)
				t = value
			elseif index == "damper" or index == "d" then
				p0, v0 = positionvelocity(time)
				d = value < 0 and 0 or value < 1 and value or 1
			elseif index == "speed" or index == "s" then
				p0, v0 = positionvelocity(time)
				s = value < 0 and 0 or value
			end
			t0 = time
		end,
	})
end
return spring
