Getting a position between two parts

Hey! I am currently looking for a method which will allow me to get a position between two parts. I have been browsing in the devforum for quite a while which didn’t give me any results.

I’ve had a similar problem, and I used ChatGPT to write me a script(yes im lazy dont judge me)
This script was intended for streching a part between two positions, but I think this is the way to do it:

	local part1Position = part1.Position
	local part2Position = part2.Position
	local desiredPosition = (part1Position + part2Position) / 2

Put this inside a loop and add a print statement to print “desiredposition”
If this doesn’t work, just say something and I’ll try my best to help you :smiley:

1 Like

Exactly what I was looking for! Thank you so much!

1 Like

Additionally, if you wanted to get a position not directly in the center you can use the :Lerp() function.

local Part1 = workspace.Part1 -- Starting point, can also be a CFrame value and not an instance
local Part2 = workspace.Part2 -- Ending point, can also be a CFrame value and not an instance

local WhereToPlot = 0.25 -- This number is clamped to the range [0, 1]
local DesiredPoint = Part1.CFrame:Lerp(Part2.CFrame, WhereToPlot) -- Returned a CFrame at the desired point plotted

print(DesiredPoint) -- CFrame
1 Like

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