How can I accurately place a part on a wall?

Pretty much I want to make a crack effect that if a projectile hits a wall it leaves a crack in the wall. Best way to do this I figured was to put a flat part with a crack decal on both sides and put it on the wall. But how can I find out where the wall is positioned? e.g if I just place it at the walls position and the wall is slightly tilted the decal wont be on the wall and will look weird.
All help is appreciated! Thanks!

I thought of using raycasting and getting the cframe of the part, setting the decal parts cframe to the instance of the raycastresult then setting it to raycast result position to get the rotation and everything correct but the decal part can still be sideways

1 Like

Raycasting returns the face normal and the position where it hit, so all you would have to do is something like this:

crack.CFrame = CFrame.lookAt(raycastResult.Position, raycastResult.Position + raycastResult.Normal)

Note that the decal should be on the front of the part.

3 Likes