function SPRING.Create(K,D,O,r,l)local V={Target=Vector3.new();Position=Vector3.new();Velocity=Vector3.new();Mass=D or 1;Force=O or 50;Damping=r or 2,Speed=l or 1}function V.Shove(K,D)local O,r,l=D.X,D.Y,D.Z if O~=O or O==math.huge or O==-math.huge then O=0 end if r~=r or r==math.huge or r==-math.huge then r=0 end if l~=l or l==math.huge or l==-math.huge then l=0 end K.Velocity=K.Velocity+Vector3.new(O,r,l)end function V.Update(K,D)local O=math.min(D*K.Speed,.1)local r=K.Target-K.Position local l=(r*K.Force)/K.Mass l=l-K.Velocity*K.Damping K.Velocity=K.Velocity+l*O K.Position=K.Position+K.Velocity*O return K.Position end return V end
-- Functions

function SPRING.Create(self, mass, force, damping, speed)
	local spring = {
		Target = Vector3.new(),
		Position = Vector3.new(),
		Velocity = Vector3.new(),

		Mass = mass or 1,
		Force = force or 50,
		Damping = damping or 2,
		Speed = speed or 1,
	}

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

	function spring.Update(self, dt)
		local scaledDeltaTime = math.min(dt * self.Speed, 0.1)

		local force = self.Target - self.Position
		local acceleration = (force * self.Force) / self.Mass

		acceleration = acceleration - self.Velocity * self.Damping

		self.Velocity = self.Velocity + acceleration * scaledDeltaTime
		self.Position = self.Position + self.Velocity * scaledDeltaTime

		return self.Position
	end

	return spring
end
