Ok well this took be almost an hour which im not proud to admit but i got it to work, i tested it and I dont see any bugs
local masterTable = {
["General1"] = {
["Sub1"] = {
"Even more sub1 11",
"Even more sub1 21",
"Even more sub1 31",
},
["Sub2"] = {
"Even more sub2 11",
"Even more sub2 21",
"Even more sub2 31"
},
["Sub3"] = {
"Even more sub2 11",
"Even more sub2 21",
"Even more sub2 31"
},
},
["General2"] = {
["General 2 sub 1"] = {
"Even more sub1 12",
"Even more sub1 22",
"Even more sub1 32",
},
["General 2 sub Sub2"] = {
"Even more sub2 12",
"Even more sub2 22",
"Test"
},
["General 2 sub Sub3"] = {
"Even more sub2 12",
"Even more sub2 22",
"Even more sub2 32"
},
},
["General3"] = {
["General 3 sub 1"] = {
"Even more sub1 13",
"Even more sub1 23",
"Even more sub1 33",
},
["General 3 sub Sub2"] = {
"Even more sub2 13",
"Even more sub2 23",
"Even more sub2 33"
},
["General 3 sub Sub3"] = {
"Hen",
"Dog",
"Cat"
},
},
}
local currentTable = masterTable
local tableHistory = {}
function assignButtonTexts(desiredTable)
local keyTable = {}
local index = 1
print(desiredTable)
for i, v in pairs(desiredTable) do
if type(v) == "table" then
script.Parent:FindFirstChild(index).Text = i
index += 1
else
script.Parent:FindFirstChild(index).Text = v
index += 1
end
end
end
assignButtonTexts(currentTable)
script.Parent:FindFirstChild("1").MouseButton1Click:Connect(function()
table.insert(tableHistory, currentTable)
local searchTable = {}
for i, v in pairs(currentTable) do
table.insert(searchTable, i)
end
currentTable = currentTable[searchTable[1]]
task.wait(0.1)
assignButtonTexts(currentTable)
end)
script.Parent:FindFirstChild("2").MouseButton1Click:Connect(function()
table.insert(tableHistory, currentTable)
local searchTable = {}
for i, v in pairs(currentTable) do
table.insert(searchTable, i)
end
currentTable = currentTable[searchTable[2]]
task.wait(0.1)
assignButtonTexts(currentTable)
end)
script.Parent:FindFirstChild("3").MouseButton1Click:Connect(function()
table.insert(tableHistory, currentTable)
local searchTable = {}
for i, v in pairs(currentTable) do
table.insert(searchTable, i)
end
currentTable = currentTable[searchTable[3]]
task.wait(0.1)
assignButtonTexts(currentTable)
end)
script.Parent.Back.MouseButton1Click:Connect(function()
if #tableHistory > 0 then
if #tableHistory > 0 then
currentTable = table.remove(tableHistory)
task.wait(0.1)
assignButtonTexts(currentTable)
end
end
end)