Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I need help I want to put 2 enemies together but how?

now the first one is running no matter what if enemy.Name = "OgreNPC or "RedOgreGeneralNPC" then

if workspace.DungeonTemp:FindFirstChild("Wave1") then 
local tableOfEnemies = game.Workspace.DungeonTemp.Wave1:GetChildren()
for _, enemy in pairs(tableOfEnemies) do
print("Wave 1")
        if enemy.Name == "OgreNPC" or "RedOgreGeneralNPC" then  --(Wave 1,5, )
            enemy.ClubHitbox:Destroy()
            print("Attack Removed")
        end
        if enemy.Name == "SnibberNPC" then  --(Wave 2, )
            enemy.StickHitbox:Destroy()
            print("Attack Removed")
        end

just those 2 enemies have the same weapon name so i wanted to put them together

2 answers

Or works different than you think, first it tries the left side of the or, in this case "OgreNPC" is it exists, is not false, then it stops there, and disregards the thing to the right. If the left hand side is nil, or false, it replaces it with the right hand side, in this case "RedOgreGeneralNPC"

You'll need to change line 05 to if enemy.Name == "OgreNPC" or enemy.Name == "RedOgreGeneralNPC" then in order to get the functionality you want

You're not comparing "RedOgreGeneralNPC" to anything so that statement considers it as something truthy.

It will pass if the first comes out false. Which is what you would want, but it's not intended when the first is also true.

if enemy.Name == "OgreNPC" or true then

You need to compare it again using == to enemy.Name.

if enemy.Name == "OgreNPC" or enemy.Name  == "RedOgreGeneralNPC" then

This discussion is preserved as it was. New answers, comments, and votes are closed.