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 » Scripting Helpers
Home Search
 

Re: Table Inception

Previous Thread :: Next Thread 
BreachedSecurity is not online. BreachedSecurity
Joined: 18 Feb 2013
Total Posts: 156
19 Jan 2014 07:45 PM
tableA = {
testA = 5;

tableB = {
testB = testA + 1;
};

}

print(tableA.tableB.testB)

20:42:30.876 - Workspace.Hit List:5: attempt to perform arithmetic on global 'testA' (a nil value)
20:42:30.877 - Script 'Workspace.Hit List', Line 5
20:42:30.877 - stack end

How would I reference testA from inside tableB?
Report Abuse
Azureous is not online. Azureous
Joined: 29 Jan 2012
Total Posts: 25287
19 Jan 2014 07:47 PM
tableB = {
testB = tableA[1] + 1;
};

print(tableB[1])
Report Abuse
ElectricAxel is not online. ElectricAxel
Joined: 15 May 2009
Total Posts: 16239
19 Jan 2014 07:50 PM
Tables don't have 'scopes'. Being inside a table doesn't mean you can access all its members as you would with variables, also, the values are not assigned in order like variables either:

tableA = {
testA = 5;
};

tableA.tableB = {
testB = tableA.testA + 1;
};
Report Abuse
BreachedSecurity is not online. BreachedSecurity
Joined: 18 Feb 2013
Total Posts: 156
19 Jan 2014 07:57 PM
So it's impossible to get members of a parent table from within a child table?

I can't even do this:

tableA = {
testA = 3;

tableB = {--INSIDE TABLE A
testB = tableA.testA + 1
};

}
Report Abuse
ElectricAxel is not online. ElectricAxel
Joined: 15 May 2009
Total Posts: 16239
19 Jan 2014 07:59 PM
Nope, like I said, they don't work like variables... Either do it the slow way or use normal variables within do blocks:

do
local TestA = 3;
do
TestB = TestA + 1;
end
end
print(TestA, TestB) --> nil, 4
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
19 Jan 2014 09:10 PM
tableA = {
testA = 5;

tableB = {
testB = tableA.testA + 1;
};

}
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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