0

I have a table with these code but can now its always show

[string "luavm"]:52: attempt to call a nil value (field 'getn')

here is my code

if IsMouseButtonPressed(1) and indexPattern < table.getn(Wpattern[indexWeapon]) or IsModifierPressed("lshift") and indexPattern < table.getn(Wpattern[indexWeapon]) then            
                MoveMouseRelative(Wpattern[indexWeapon][indexPattern].x*sensibility[indexWeapon]* RecoilSense, Wpattern[indexWeapon][indexPattern].y*sensibility[indexWeapon]*RecoilSense)
                Sleep(delay)
                indexPattern = indexPattern + 1
            else
Egor Skriptunoff
  • 23,359
  • 2
  • 34
  • 64

3 Answers3

1

The version of Lua you are using doesn't provide getn method, as it's been deprecated since Lua 5.1. You can use the length (#) operator to get the number of elements in a table without holes (nil values).

Paul Kulchenko
  • 25,884
  • 3
  • 38
  • 56
0

I guess your Lua version not match your script code. try lua 5.0 that support table.getn

Renshaw
  • 1,075
  • 6
  • 12
0

Take a look at this question on how to add table.getn yourself.

koder
  • 2,038
  • 7
  • 10