That first picture looks a lot like a bezier curve. A picture looking at it from the origin to the finish would help out a lot in determining how you would go about it.
From the look of it, they’re staggered or organized in some way that’s not perfectly linear, so I don’t think so.
If so, here is the place file for it Points.rbxl (21.7 KB)
Script:
local function CreatePoints(startPos, endPos, segments)
local model = Instance.new("Model")
model.Name = "Points"
model.Parent = workspace
for i = 0, segments do
local offset = Vector3.new(math.random(-1, 1), math.random(-1, 1), math.random(-1,1))
local newPos = startPos + (endPos - startPos).Unit * i * (endPos - startPos).Magnitude / segments
if i == 0 or i == segments then
offset = Vector3.new(0, 0, 0)
end
local point = game.ReplicatedStorage.Point:Clone()
point.Position = newPos + offset
point.Parent = model
end
end
local startPart = workspace.Start
local endPart = workspace.End
CreatePoints(startPart.Position, endPart.Position, 10) --Last argument is the amount of points you want
Yea sure. First there is a function that creates the points. It takes in a start position and an end position which are both Vector3 values. The 3rd parameter is the amount of segments which you can think of as the amount of points.
Next, there is just a model to store all the parts. After that there is a for loop which will loop from 0 to however many segments there are. This will create a point each iteration. The offset makes it so the points are placed randomly. Without this, it will just be a straight line of points that are spaced evenly.
Now the math. We start by getting the start position and adding
(endPos - startPos).Unit
This creates a 1 stud vector that is “facing” the end position. Adding this creates a line that is positioned at the start position and faces the end position. We next multiply this vector by ‘i’ which is the index of the loop. This is what moves the point forward. Since we start at the number 0, multiplying a number by 0 is always 0 which places it right on the start position. The bigger the number, the farther forward it gets.
(endPos - startPos).Magnitude / segments
This section first gets the vector length of the two points using Magnitude. This is the distance between the two points. We divide this by the number of segments so the part is spaced evenly.
if i == 0 or i == segments then
offset = Vector3.new(0, 0, 0)
end
This is an if statement that checks if the current part is the first part being made, or the last part. We need to check this so the parts are centered in the first and last part. You can see in the picture that both the green and red points have a part placed in them. Overall, it just removes the offset if it’s the first or last iteration.
Lastly, we position the part and add the offset to make it a random line of points.