Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Find the center of a model?

I don't want to manually set a part in the middle as the primary part, so any ideas how to do the math or whatever I need to do?

Or how to find the nearest model to a Vector3, that's what I'm trying to do with this in the end

Thanks in advance!

1 comment

0

Perhaps if you get a vector3 for the center of the model you could store that in a Vector3Value object and calculate the distance/magnitude between the two models by subtracting their Vector3 positions

1 answer

✓ Accepted answer

Hmm, I guess you could add the positions of all the parts in the model and find the average. For instance, if you have 24 parts in a model, you would add all of the parts' positions and then divide them by 24. That should give a center, but maybe I am wrong, I do not know. Sorry I didn't give a script, it should be simple, probably lots of variables though if you have a lot of parts...

5 comments

0

You could use a for loop instead of having to reference every single part

0

Yes, that would work better than referencing each part.

0

Yea I was just watching youtube and I thought "why am I so stupid I could average the positions" then I came here to delete the question

0

Wait no that wouldn't do what I want, if there's more parts to 1 side it's gonna be closer there...

0

At this point, I recommend just having an invisible center part as the PrimaryPart...

This discussion is preserved as it was. New answers, comments, and votes are closed.