Weird "attempt to index a nil value" error (SOLVED)

#1
print( noise[octave][x][pointStart].land )

This is my code. Everything in it is specified and resulting in the desired value to be seen in the console.
Despite that, an error message still says “attempt to index a nil value” in exactly that line, resulting in the code not working. Why? And how can I fix this?

btw how do you make code blocks in forum posts

0 Likes

#2

Try to find out where exactly the problem is:

print(noise[octave])
print(noise[octave][x])

etc…
Also:

 pprint(noise)

Four spaces at the beginning of a line.

1 Like

#3

Thanks for the quick reply.
Turns out there was just something I didn’t take into account, that the line i mentioned would be called twice, resulting in a decimal number being used the second time. The first call resulted in the line doing what it should do, the second resulted in an error. I first thought the error also happened in the first call, so yeah. Thanks for the help anyway!

0 Likes

#4

No problem! I’m always glad to see a question where I actually can be helpful. And “attempt to index a nil value” used to be the bane of my existence for a long time.

1 Like