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

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

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

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!

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