ShinyHobo
|
  |
| Joined: 19 Apr 2013 |
| Total Posts: 112 |
|
|
| 06 Aug 2015 10:20 PM |
Heyo~
I keep getting this error:
23:17:31.964 - Workspace.fourDoors.conTwo.sNR_v2:49: attempt to index field '?' (a nil value)
when attempting to run this portion of the script:
if _G.roomExist[x][z] == nil then
If it is a nil value, how come the script stops working? How can I get around this? |
|
|
| Report Abuse |
|
|
| |
|
ShinyHobo
|
  |
| Joined: 19 Apr 2013 |
| Total Posts: 112 |
|
|
| 06 Aug 2015 10:27 PM |
| Using pcall is not the help I am looking for. I wish to use the fact that it -is- a nil value. |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2015 10:28 PM |
if not _G.roomExist[x][z] then --c0d3 end |
|
|
| Report Abuse |
|
|
ShinyHobo
|
  |
| Joined: 19 Apr 2013 |
| Total Posts: 112 |
|
|
| 06 Aug 2015 10:32 PM |
| That yields the same error. |
|
|
| Report Abuse |
|
|
ShinyHobo
|
  |
| Joined: 19 Apr 2013 |
| Total Posts: 112 |
|
|
| 06 Aug 2015 11:06 PM |
After a bit of fiddling around, I fixed it using this knowledge, thank you.
if not _G.roomExist[x] then _G.roomExist[x] = {} end if not _G.roomExist[x][z] then _G.roomExist[x][z]=0 --code end |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2015 11:09 PM |
welcome
dont use == true or == false btw
use
for true:
if var then
for false:
if not var then
^saves memory |
|
|
| Report Abuse |
|
|