As you can see from the pictures the red part is not touching anything.
The walls that you can see is a meshpart.
When using GetPartBoundsinBox it tells me that the red part is “touching” the walls even tho it isnt, because it treats the mesh as an entire cuboid so the empty spots in the meshes are also “touching the red part”
Is there another function that I can use to check parts inside an area more precisely or should I additionaly make a raycast to check if its actually touching or not. (not even sure if raycasts are going to print the touching wall)
You can try changing the collision fidelity. There is a precise option which tells it to only consider the actual shape the model makes. Though I’m not sure how that interacts when something doesn’t have volume. (So giving it volume might work here)
You can split your mesh into regions where inaccuracies can be accounted for. (So like each wall it’s own mesh)
You can make them no can collide and no query and put boxes there purely for query.
You can have a part in the middle designed to tell you that the past you are interested in is not touching am edge because touching that part would be impossible at the same time.