Glua error "attempt to call method 'GetPlayerVisible' (a nil value)"

34 views Asked by At

I personally don't know how a built in function can be indexed as "nil" butthis error appeared and it haulted my nextbot's movement. heres my code that is causing this

if (!self:GetPlayerVisible() and chasing_timer > chasing_time) then
           self.stopchasing = true
           self.enraged = false
           print("Chase stopped")
           print("Increasing escaped chases count, new:", self.escapedchases)
           self.escapedchases = self.escapedchases + 1
       end

I tried replacing the "!" with "not" but it did nothing.

1

There are 1 answers

3
Piglet On

I don't know what self is but that table does not contain an element GetPlayerVisible. Hece you may not call it. Calling nil values doesn't make sense.

Ask yourself why you think this function exists. Typical reasons are typos, indexing the wrong table or not having implemented a function yet.

To avoid this error you basically have two options. Make sure you call something that exists, or don't call it.