I have a bunch of randomly dispersed parts, and i need the average position of them. I can't figure out how to do it with for loops.
✓ ANSWER ACCEPTED
How do i find the average position of a group of objects?
1 answer
✓ Accepted answer
just do this loop through each one and add the vector3 pos together! might work not sure about the list.
local acc = vector3.new(0, 0, 0)
local partlist = {}
partlist.part1 = worspace.Part1 -- change these and add new ones if needed
partlist.Part2 = worspace.Part2
partlist.Part3 = worspace.Part3
for _,part in pairs(partlist) do
acc = acc + part.Position
end
local avgx = acc.X / #partlist
local avgy = acc.y / #partlist
local avgz = acc.Z / #partlist
local avg = vector3.New(avgx, avgy, avgz)
print("finished!")
This discussion is preserved as it was. New answers, comments, and votes are closed.

6 comments
Thank you alot lol
hey, can you please accept the answer? It would mean a lot.
First time i've ever used this site, i'll try to figure out how :p
Under the upvote and downvote theres a circle in a check, click it to accept the answer
There's nothing there
Just hover over the name and to the right I think