How to tell if Part.Touched is flat

I am making a grenade that only explodes on flat surfaces.

I am using the part.Touched event to tell if the grenade hit something, but I am wondering how I can tell if the part it touched is a flat surface.

You could maybe check if the Orientation of the Part it touches is flat?

I think you can add a BoolValue to the Part to determine whether it’s flat or not? I was gonna say my first thing, but just realized that the Orientation cannot be replicated server or client wise

Well there are cubes in my game, the grenade should be able to land on top, but not on the side.

You can raycast downwards after the grenade touches something. The RaycastResult returns a Normal which you can use to determine where the part under the grenade is looking

what would the normal be if it is flat?

The Normal is a unit vector that is perpendicular to the surface where the raycast hit. You would have to get the angle between the Normal vector and Vector3.new(0, 1, 0) which is a vector for a normal that faces straight up

1 Like