function SPRING.create(g,h,l,V)local G={Target=Vector3.new();Position=Vector3.new(),Velocity=Vector3.new(),Time=0,Mass=g or 5,Force=h or 50;Damping=l or 4,Speed=V or 4}return setmetatable(G,Meta)end function SPRING.shove(h,g)local l,V,G=g.X,g.Y,g.Z if l==math.huge or l==-math.huge then l=0 end if V==math.huge or V==-math.huge then V=0 end if G==math.huge or G==-math.huge then G=0 end h.Velocity+=Vector3.new(l,V,G)end function SPRING.update(h,g)local l=math.min(h.Time+g*h.Speed,FixedRate*MaxSkips)for g=1,math.floor(l/FixedRate)*ITERATIONS,1 do local V=h.Target-h.Position local G=(V*h.Force)/h.Mass G-=h.Velocity*h.Damping h.Velocity+=G*iterdt h.Position+=h.Velocity*iterdt l-=iterdt end h.Time=l if h.Position.Magnitude>1e-05 then return h.Position end return Vector3.zero end
-- Functions

function SPRING.create(mass, force, damping, speed)
	local spring = {
		Target = Vector3.new(),
		Position = Vector3.new(),
		Velocity = Vector3.new(),
		Time = 0,

		Mass = mass or 5,
		Force = force or 50,
		Damping = damping or 4,
		Speed = speed or 4,
	}

	return setmetatable(spring, Meta)
end

function SPRING:shove(force)
	local x, y, z = force.X, force.Y, force.Z
	if x == math.huge or x == -math.huge then
		x = 0
	end
	if y == math.huge or y == -math.huge then
		y = 0
	end
	if z == math.huge or z == -math.huge then
		z = 0
	end
	self.Velocity += Vector3.new(x, y, z)
end

function SPRING:update(dt)
	local Time = math.min(self.Time + dt * self.Speed, FixedRate * MaxSkips)

	for i = 1, math.floor(Time / FixedRate) * ITERATIONS do
		local iterationForce = self.Target - self.Position
		local acceleration = (iterationForce * self.Force) / self.Mass

		acceleration -= self.Velocity * self.Damping

		self.Velocity += acceleration * iterdt
		self.Position += self.Velocity * iterdt
		Time -= iterdt
	end

	self.Time = Time
	if self.Position.Magnitude > 0.00001 then
		return self.Position
	end
	return Vector3.zero
end
