Is there a way to detect the nearest surface to a player?

Hello DevForums! I am still currently working on a web swinging system with little to no success. My next method I am trying right now is to find a nearby surface in order to place an attachment onto it. I however, do not know how to find the nearest surface from the player in order to place an attachment onto it. Is there some method that allows me to check the nearest surface?

I think you should be able to do it by creating a sphere, then check the parts touching the sphere. Using the table of parts collected by the sphere you can run a loop check every part to see the distance from the player using magnitude. All you have to do now is just create the attachment.

If you want the web to look better you could use raycasting and cast a ray from the player to the part that you found and create the attachment there where the raycast hit.

Hope this is helpful, best of luck.