How to filter out player characters in RaycastParams?

Hello! I am currently trying to make a tower defense game and currently working on the troops. However, I have come across a major bug that can ruin gameplay. If the player is in the way of the Raycast direction, the raycastResult will hit the player and not at the enemy mob. Note, the player doesn’t take damage because I made it only damages mobs.

How would I use RaycastParams to filter out all of the player characters?

The easiest method would probably be via Collision Groups:

Just do Raycast FilterDescendantsInstance = {Player.Character)

this is on a server sided script.

Actually, that method might be easier now that I think about it.


Due to it taking an array, you can just insert characters into the array as they spawn. From what I can remember, Collision Groups don’t take models, only BaseParts.