A little help needed with my missile sent.

So far so good. Everything works.

Except that once I added an explosion to the ent, and tried to fire it, it said tried to use a NULL entity.

So if you can help… Here is the part of the code that I believe is causing the error…

function ENT:Touch(ent)
	if ent:GetPhysicsObject():IsValid() or ent:IsWorld() or ent:IsPlayer() or ent:IsNPC() then
		local pos = self.Entity:GetPos()
		local explode = ents.Create( "env_explosion" )
		explode:SetPos( pos )
		explode:SetOwner( self.Owner )
		explode:SetKeyValue( "iMagnitude", "75" )
		explode:Fire( "Explode", 0, 0 )
		explode:EmitSound( "weapon_AWP.Single", 100, 100 )

thnx :slight_smile:

Maybe try the OnCollide hook!

I’m not sure how to use that…

It should say self:Remove(), not self.remove

And you also ought to try the physicscollide function instead. You obviously don’t need to act on any of the info you’re given, since it’s gonna pop every time it hits anything.

Yea what Morcan said, also why are you checking if the object you hit is valid? seems a bit unnecessary since you can’t touch invalid objects.

Great now ima go test it out



it’s no longer null but the explosion doesn’t spawn…

Ddd an index to the sent_explode maybe :colbert:

What line is the error occuring on?

There is no error…

I just can’t get the explosion to spawn.