generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Cannot Index Nil Value

Previous Thread :: Next Thread 
ShinyHobo is not online. 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
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
06 Aug 2015 10:22 PM
look up pcall
Report Abuse
ShinyHobo is not online. 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
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
06 Aug 2015 10:28 PM
if not _G.roomExist[x][z] then
--c0d3
end
Report Abuse
ShinyHobo is not online. ShinyHobo
Joined: 19 Apr 2013
Total Posts: 112
06 Aug 2015 10:32 PM
That yields the same error.
Report Abuse
ShinyHobo is not online. 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
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image