How do I check the closest parts to a part?

What I’m trying to say is how do I find and check the closest parts to a selected part.

|

(All the parts are named differently)
Say the selected part is the red part, I want to check the four blue parts for their names.
image

|

If it does not make cense just let me know and I’ll try to explain it better.
(I do not want to use a For loop because their are too many parts)

2 Likes

Perhaps you could have a dictionary where
[Position] = Part
And you just index those positions by adding and subtracting by 1 on the x and z axis

2 Likes

probably could use .magnitude since that’ll give you the distance between a part and another in studs from the center iirc.

Where would I put this dictionary, because I need it to be accessible by both local and server scrips

2 Likes

I don’t think thats what OP wanted. OP said they want to find the touching parts, not their distance.

2 Likes

The server and the client can both create the dictionary if the parts are created on the server.

Is it possible to send the table over by RemoteFunctions?

1 Like

I don’t want the distance I want the parts touching it.

right but you could probably use it and then see which is the closest and then use that as the closest parts to a part.

yeah, I think that could be possible.

They said they don’t want a for loop.

1 Like

I have too many parts to use a for loop.

oh ok well

is probably the best thing you could do with it

Yeah, that’s probably how I will do it.