I have a script that when a gun is shot it would cast a decal depending on the material it hits. For example if it hits plastic it will be a regular bullet hole, if it hits wood it would look like a wood bullet hole, and if it hits a player it would be a flesh wound. However if the player shoots a wound twice it would register that the player hit a plastic part instead of the player. How would I go on ignoring the flesh wound part that’s welded to the humanoid and instead just add another flesh wound instead of a bullet hole. The way my gun works is projectile based, they run off of OnTouched(). Im thinking about using different collision groups to bypass that but I am not sure if it would work or if there are more efficient methods.
If you don’t want to use CollisionGroups, then you could possibly create your own ignore table and inside the Touched check that the part you hit isn’t in the ignore table with a supplementary function:
local Ignore = {}
table.insert(Ignore, Wound)
local function notIgnored(part)
for _, ignoredPart in ipairs(Ignore) do
if ignoredPart == part then
return false
end
end
return true
end
Projectile.Touched:Connect(function(hit)
if notIgnored(hit) then
--// Code
end
end)
Alternatively, you could use Rays and :FindPartOnRayWithIgnoreList() which would possibly be much easier and something that I’d prefer to use.
As Returned said, You could do raycast ignorelist create a Folder in the workspace and then put a bullethole’s parent inside the folder you created in the workspace and then when you do a raycast, you will raycast it and then ignore the Part inside the folder or to be exactly, workspace:FindPartOnRayWithIgnoreList(ray,workspace[Your Folder’s Name]) --don’t forgot to put the player’s character inside the ignorelist