How would i check if what part is next to a part?

(DISCLAIMER: I am not asking for people to write scripts for me)

Let’s say that I wanted to check if any part are next to another part

Take this picture as an example:

(don’t judge me about how bad this picture are, I’m on hurry)

Any helps are appreciated! :slight_smile:

U can make something like this

local part1 = workspace.Part1
local part2 = workspace.Part2

    if part1.Position + part2.Size.X == part2.Position then
     print(“part2 is next to part1”)
    end

There’s different ways of doing that but thats the first thing that came to my mind.

Sorry, it didn’t work (There’s an error and I fixed the error but it’s still doesn’t work)

This exact code won’t work for you i’m just giving you the way it could work for you if u use this method

I am testing it first before using it and it prints out an error?

(I am modifying it to see if it works)

If it doesn’t work try switching X with Z i can’t tell where your parts are located

I modified it a bit and it works

Thanks!

1 Like