function module.create(d,C,G,W,q)local Y={Target=Vector3.new(),Position=Vector3.new(),Velocity=Vector3.new();Mass=C or 5;Force=G or 50,Damping=W or 4;Speed=q or 4}function Y.SetBaseValue(d,C)d.Target=C d.Position=C d.Velocity=C end function Y.Shove(d,C)local G,W,q=C.X,C.Y,C.Z if G~=G or G==math.huge or G==-math.huge then G=0 end if W~=W or W==math.huge or W==-math.huge then W=0 end if q~=q or q==math.huge or q==-math.huge then q=0 end d.Velocity=d.Velocity+Vector3.new(G,W,q)end function Y.Update(d,C)local G=(math.min(C,1)*d.Speed)/ITERATIONS for C=1,ITERATIONS,1 do local W=d.Target-d.Position local q=(W*d.Force)/d.Mass q=q-d.Velocity*d.Damping d.Velocity=d.Velocity+q*G d.Position=d.Position+d.Velocity*G end return d.Position end return Y end
-- Functions

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

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

	function spring.SetBaseValue(self, V)
		self.Target = V
		self.Position = V
		self.Velocity = V
	end

	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, 1) * self.Speed / ITERATIONS

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

			acceleration = acceleration - self.Velocity * self.Damping

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

		return self.Position
	end

	return spring
end
