What I meant by my comment was you need to have it one of two ways:
I removed the first one because you shouldn't use it and apparently including it, and telling you not to use it to show you what not to do is wrong?
Now the one you should use is this one, it will loop twice through the if statement you already have:
for i=1,2 do
if enemy.Name == "ShellMouthNPC" or enemy.Name == "ForestShellMouthNPC" then
enemy.TreeHitbox:Destroy()
print("Attack Removed")
end
end
This last one I didn't mention in my comment because it requires a bit more work, but it will be more helpful to you in the long run than the other two.
Now you could get even more fancy and store the enemies in a table and make the for loop even more useful:
for i,v in pairs(enemy) do
if v.Name == "ShellMouthNPC" or v.Name == "ForestShellMouthNPC" then
v.TreeHitbox:Destroy()
print("Attack Removed")
end
end
i is the number of times the loop iterates (how many times it loops), and v would be each enemy inside the table called "enemies". With this way you could easily check for any property of each enemy by checking for v.Property where Property would be whichever property you want to check for. This also allows you to edit each enemy's property as well.
6 comments
you only have it destroy one of them though, if you want to destroy both, you have to run it in a loop or have two if statements.
you could also use a bit of string manipulation to shorten your code
Do you have more code you could share? You could try doing this with a :FindFirstChild(enemy.Name) check.
what do youmean by string manipulation
What he meant by that is why are your strings so long?
if enemy.Name == "ShellMouthNPC" then --(Floor 8, 10) enemy.TreeHitbox:Destroy() enemy.Parent:FindFirstChild("ForestShellMouthNPC").TreeHitbox:Destroy() end