For example,
local dictionary = {["cow"] = 1, ["sheep"] = 1}
local random = dictionary[math.random(1, #dictionary)]
print(random) --This would print 1
but how do I get the name of where the 1 came from?
local dictionary = {["cow"] = 1, ["sheep"] = 1}
local random = dictionary[math.random(1, #dictionary)]
print(????) --This would print where the 1 came from

1 comment
When you fix this, you should add "math.randomseed(os.time())" in the beginning so you don't always get "cow" or "sheep" at every run.