Answered by
6 years ago Edited 6 years ago
Well, if you destroyed the script's parent on the first iteration, the parent will not be existent anymore. Nil is the same thing as nothing, null, nonexistant, void.
If it manages to go through the if condition twice, it will try to destroy something that is not there. So, it will attempt to destroy nothing.
And, since Lua hates when something goes wrong (unlike html), it will error and cry under the sheets. So, you want to prevent that, right?
To prevent it, just check if the script has a parent, and if the script's parent's parent is available.
TL;DR, you should check if the scripts parent (and the script's parent parent) isn't nil.
P.S.
To save yourself another line, instead of doing
3 | print 'green eggs in ham still hates sam i am' |
you can do:
2 | print 'green eggs in ham still hates sam i am' |