Create parts with a 2 stud gap in between a start and end point

Probably a super basic question, but how would I go about creating a script that creates 1x1x1 parts with a 2 stud gap in between a start and end point?

1 Like

You would probably have to do something with a for loop.

let me know if this works or if this is what you wanted:

local function CreateStud(Position)
	local Part = Instance.new("Part")
	Part.Size = Vector3.one
	Part.Anchored = true
	Part.Position = Position
	Part.Parent = workspace
end

local Start = workspace.Start
local Goal = workspace.Goal

local StartPos = Start.Position
local GoalPos = Goal.Position

for I = 1, math.floor((StartPos - GoalPos).Magnitude / 3) - 1 do
	CreateStud(StartPos + -(StartPos - GoalPos).Unit * (I * 3))
end


1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.