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

OgreNPC is alive but it does warn none.. What am I doing wrong?

it checks what wave is current, then checks the enemy name and destroys the hitbox of their weapon

OgreNPC is alive but it does warn none

if workspace.DungeonTemp:FindFirstChild("Wave1") then 
local tableOfEnemies = game.Workspace.DungeonTemp.Wave1:GetChildren()
for _, enemy in pairs(tableOfEnemies) do
print("Wave 1")
        if enemy == OgreNPC then
            enemy.ClubHitbox:Destroy()
        end
        if enemy == RatdogNPC then 
            enemy.HeadHitbox:Destroy()        
        else
            warn("None of these enemies")
        end
        
end

1 answer

✓ Accepted answer

First of all, you might wanna use elseif and else in the end, since that your current "else" only outputs if it's not a "RatdogNPC"

Here,

if workspace.DungeonTemp:FindFirstChild("Wave1") then 
local tableOfEnemies = game.Workspace.DungeonTemp.Wave1:GetChildren()
for _, enemy in pairs(tableOfEnemies) do
	print("Wave 1")
        if enemy == OgreNPC then -- if OgreNPC
            enemy.ClubHitbox:Destroy()

        elseif enemy == RatdogNPC then --if not OgreNPC but is RatDogNPC
            enemy.HeadHitbox:Destroy()        
        else
            warn("None of these enemies") -- if it's none of them
        end

end

Plus, not sure, but you might wanna check the "Name" property of the enemy(?), and quote the NPC's name

enemy.Name == "RatdogNPC"

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