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

Table Navigation - How do I navigate tables within tables and so on?

Given code: (Oh boy, who am I kidding...)

local keys = {}
local zCombos = {}
local xCombos = {}
local cCombos = {}

local zCombo1 = {}
local zCombo1Keys = {
Enum.KeyCode.Z,
Enum.KeyCode.X,
Enum.KeyCode.C
}
local zCombo1Anims = {
RisingPunch,
FallingPunch,
StraightPunch
}
table.insert(zCombo1, zCombo1Keys)
table.insert(zCombo1, zCombo1Anims)


local zCombo2 = {}
local zCombo2Keys = {
Enum.KeyCode.Z,
Enum.KeyCode.C,
Enum.KeyCode.X,
Enum.KeyCode.C
}
local zCombo2Anims = {
RisingPunch,
StraightPunch,
FallingPunch,
StraightPunch
}
table.insert(zCombo2, zCombo2Keys)
table.insert(zCombo2, zCombo2Anims)

table.insert(zCombos, zCombo1)
table.insert(zCombos, zCombo2)

Goal: Loop throughout the hierarchy of tables, starting with zCombos, and print any Enum.KeyCode that are found along the way.

Parameters:
zCombo1Keys - A series of Enum.KeyCode
zCombo1Anims - A series of Animation instances
zCombo2Keys - A series of Enum.KeyCode
zCombo2Anims - A series of Animation instances
zCombo1 - A table holding zCombo1Keys and zCombo1Anims
zCombo2 - A table holding zCombo2Keys and zCombo2Anims
zCombos - A table holding zCombo1 and zCombo2

How do I complete the Goal?

Answer below...

1 answer

you can go into tables by putting the name of the tables, square brackets, and the number of the object. for example

local table = {'test string', 'another test string'} --Example table

print(table[1]) --this prints the first object, which is a string

1 comment

0

oh yea also u can use a for loop to go through each object and find the keycodes lmao, im not good with the uis

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