Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I access the largest table?

local largest = {
	iWantToAccessThisVariable = nil,

	local smaller = {
		InsideFunction = function(self)
			--[[
			the problem is, "self" refers to the array named "smaller", but I want to access the 					 
 array named "largest" in order to get to iWantToAccessThisVariable.

			using largest.iWantToAccessThisVariable does not work
			--]] 
		end
	}
}

ignore any insignificant syntax errors, I didn't compile this in studio

2 comments

0

syntax errors are pretty significant since they create errors

0

smaller isn't an array, it's a dictionary

1 answer

Your code contains a syntax error. The local shouldn't be before "smaller".

Now, if you explained why do you need to do somethint like this, I could perhaps propose a better workaround, but for now let's work with your code.

If you want to access the largest table from the function inside the smaller table, you should first define the largest variable as a nil value, and then assign the table to it, like so:

local largest --here, see?
largest = {
	iWantToAccessThisVariable = nil,
	smaller = {
		InsideFunction = function(self)
			
		end
	}
}

This discussion is preserved as it was. New answers, comments, and votes are closed.