My game contains NPCs that help shoot zombies. However, the script I created to fire the lasers that the NPCs shoot does not check for parts between the NPC and the Zombie. I’ve been working to detect these parts, and use FindPartOnRayWithIgnoreList to prevent shooting a zombie if it is blocked by a wall. I happen to have certain entire models that I would like to ignore, models that contain parts and other objects. What is the easiest way to ignore all Part class descendants of multiple models and store them in an IgnoreList?
The documentation of FindPartOnRayWithIgnoreList states the ignore list is to be an array.
Create an array that contains all the parts and models that you want the Ray to ignore.
It works with Models as well, so anything parented under a model in the array will also be ignored.
I don’t quite understand what you’re asking but you could probably just iterate through :GetDescendants() and check if the object is a class that you want to ignore, and if so, add it to the ignore list array.
FindPartOnRayWithIgnoreList does this already. The list of instances you provide adds each instance and all of its descendants to the ignore list. You don’t need to manually build the ignore list using GetDescendants() calls.
You can’t write your own hit test filter though, if you only want to add specific instance types, then you have to pre-filter in Lua (with IsA or ClassName comparisons), OR, create sub-models of all of the things you want ignored, within the model (fast, visual, but often impractical for large constructions).
I’ve been printing the part that they detect, and it still seems to not ignore any of the parts in the array.
here is the hierarchy for the shooting script
Script.Parent refers to the handle, (Just realized I don’t need this since its in the NPC anyways)
Script.Parent.Parent.Parent refers to the NPC
owner refers to my characterer
temp.parent refers to the zombie it is aiming for.
It might be enlightening to print out the hit part, and hit.Parent, so you know whose body parts those are (assuming your character, the npcs and zombies are all R15s). Is it just shooting through to the first non-ignored npc, zombie or character? Impossible to tell without knowing your test scenario.