function ENT:FindEnemy() -- Search around us for entities -- This can be done any way you want eg. ents.FindInCone() to replicate eyesight local _ents = ents.FindInSphere( self:GetPos(), self.SearchRadius ) -- Here we loop through every entity the above search finds and see if it's the one we want for k, v in pairs( _ents ) do if ( v:IsPlayer() and v:Health() > 0) then -- We found one so lets set it as our enemy and return true self:SetEnemy( v ) return true end end -- We found nothing so we will set our enemy as nil ( nothing ) and return false self:SetEnemy( nil ) return false end
I need help changing this code up a bit for my NextBot NPC. I need to make it find only my other Nextbot entity by it’s class(class is simple_nextbot)
Can anyone help?