How to get the dictionary inside of a dictionary using the given parameter?

local dictionaryA = {
    dictionaryB = {
        partC1
        partC2
    }
}

function Func(intA, intB)
    print(dictionaryA.intA[intB])
end

Func("dictionaryB", 2)

I am trying to make it print PartC2,
but this obviously didn’t work, is there a way to do this like you would with FindFirstChild()?

:FindFirstChild can only be used on Instances (such as Parts, Models, etc)

To access a table using a given key, you have to use square brackets []

print(dinctionA[intA][intB])
2 Likes

You should instead use

dictionary = {
{part1, part2}
}

and have the function

dictionary[1][2]

2 Likes

ah Thank you very much it worked!

thank you very much Mr. Taco!!