Is :GetTouchingParts() more expensive or casting a ray

If I were to run :GetTouchingParts() every wait() vs raycast every wait() to detect if a rocket has made contact with a surface, which one is better used? Or are there alternatives? The rocket must be anchored so I cannot use the Touched event.

Seems more like a matter of the pros and cons of each method. There is no real objective position on the matter but some things may work better than others. Most of these methods are bottlenecked primarily by inherent slowness checking hits on the server done by clients or hit legitimacy if hits are checked and sent by the client to be registered.

I would assume the main reason melee systems dislike using Touched is because of the need for physically simulated objects to intersect. I’ve used a Touched system for a PvP project back in 2018/2019 and I had countless complaints about hit detection being horrible. Part of this was because I did not handle already-intersecting parts correctly (nor did I know how at the time).

Personally I think Touched is still fairly viable and you’re free to use it so long as you can handle the various cases around it. I preference raycasting now though because you don’t actually need to rely on physics simulation or anything to get your hits done, meaning that even stationary objects that should deal melee damage can do so. After being opened to the world of raycasts for melee, never looked back. Unless I’m lazy and that’s a different story altogether, touched has a slight delay compared to raycast .

It’s not for a melee system. Its for a rocket which has to be anchored so I can’t use Touched.

:GetTouchingParts() is far from ideal. Raycasting is inexpensive when doing short rays.
Stick with raycasting, or alternatively check out OverlapParams, it’s similar to raycasting in it’s setup but allows you to do quite a few things with it.
https://developer.roblox.com/api-reference/datatype/OverlapParams

GetTouchingParts only works when a BasePart has CanCollide on or has a TouchInterest
https://developer.roblox.com/en-us/api-reference/function/BasePart/GetTouchingParts

GetTouchingParts is less expensive than Raycast. But you can also use Workspace:GetPartsInPart(Part, OverlapParams). Both this and GetTouchingParts have the same effeciency. But GetPartsInPart ignores all collision stuff of a part.

Do you happen to know the surface beforehand? For a more efficient alternative, you can just use math if you already know the surface. When you are able to fill in more variables to a problem, it becomes a lot easier to solve for. Otherwise, you can get a little creative if you are dealing with n surfaces. You could determine the average height of all surfaces (x) then compute the distance from the rocket to x and determine an optimal threshold for when you should raycast since shorter raycasts are considerably cheaper otherwise query surfaces and figure collisions like that.