How do i randomly spawn objects between 2 CFrames or if there is a easier way?
I assume you mean on the line segment between the two CFrames' position. In this case, it's as simple as:
local start = cf1.p local finish = cf2.p local displacement = finish - start local point = start + displacement*math.random()
Try to visualize the math in your head. As game developers we think of vectors as arrows in space. They can also be thought of as points.
In this case,
start
and finish
are two points corresponding to your CFrames' position; anddisplacement
is an arrow that starts from one of the points and reaches the other.Now, to get a new, random point between these two points we simply stretch that displacement vector by a random factor comprised between 0
and 1
. We can think of this number as a percentage of the distance between our two points.
We then add this new stretched displacement vector back to the first point to get our new random point.