SWep: apc_missile problem.

Hi, I scripted it:



	if !IsValid(self.rocket) then return end
	
	for k, v in pairs(ents.FindInSphere(self.rocket:GetPos(), 10)) do
	if (v:GetClass() == "npc_gunship" || "npc_strider" || "npc_helicopter") then
	self.rocket:SetHealth(0);
	self.rocket:EmitSound("")
	end
	end


but when the rocket hitting these npcs it’s not falling down! help!

Im not really experienced with lua but you can use http://wiki.garrysmod.com/page/ENTITY/PhysicsCollide this to detect if its colliding with anything then just use the FindInSphere to find players/ents/npcs and damaging them i hope thats what your asking becuase i dont really get the "rocket hitting these npc’s its not falling down"I hope this helped :slight_smile:

That’s not how you use ‘or’ (||), it is only actually checking against “npc_gunship”

[lua]if (v:GetClass() == “npc_gunship” || “npc_strider” || “npc_helicopter”) then[/lua] would need to be
[lua]if (v:GetClass() == “npc_gunship” || v:GetClass() == “npc_strider” || v:GetClass() == “npc_helicopter”) then[/lua]
For readability my personal preference is:
[lua]
local class = v:GetClass()
if (class==“npc_gunship”) or (class==“npc_strider”) or (class==“npc_helicopter”) then[/lua]
although if you are going to ever add more classes it might be better to store them as keys in a table and check for their existence.