Tryed using null entity error, even with isValid checks

Well, i’m having a really weird error over here. i’m trying to make a entity to use another entity ( like wire user for example ) the issue here is that it will always flag the entity as null. It doesnt matters which entity i use, since i’ve tryed doing self:use(ply,ply,etc,0). This entitys are NOT null, i tryed using the isValid and ent && ent:isValid methods to check. I even tryed changing the entity to self and try checking if it would loop or something, but i got the same error. Might be the function is not working as it should?

[lua]

engineEntity = self:engineDetect() // will always output only one entity.

if engineEntity and engineEntity:IsValid() then engineEntity:Use(self:GetOwner(), self:GetOwner(), USE_ON, 0) else return end // also Tryed IsValid(engineEntity) and it wont work.

[/lua]


 if IsValid(engineEntity) then ... end 

This is the correct way to do it if you don’t know if the variable is nil or not.
IsValid does the nil check itself, so you don’t have to.

If that’s not working, then the issue might be from something else, or the entity wasn’t reloaded - still using the old code.

random question I’ve yet to figure, is there any real difference to using IsValid vs (not var) for checking validity?

Entities can be non-nil and still invalid. A deleted entity, for example.

As i said in the post i did tryed with IsValid first. Then, i also reloaded entities and server. I’ll will have to find a alternate solution then. thanks tho