I just made this script up, and I know it probably sucks that you can’t put exactly "Shotgun" == Weapons, and because of lots of things. Maybe there is a better way, but this should be fine for now.
local Tables = {
Weapons = {
-- PRIMARY
["Shotgun"] = "Shotgun",
-- BACKUP
["PixelGun"] = "PixelGun",
["CombatKnife"] = "CombatKnife",
-- SPECIAL
["SniperRifle"] = "SniperRifle",
-- PREMIUM
["SignalPistol"] = "SignalPistol",
}
}
local function locateTable(value)
for i,v in pairs(Tables) do
for i2,v2 in pairs(v) do
if i2 == value then -- Or v2 (I don't know what you're trying to do)
return v
end
end
end
return nil
end
print(locateTable("Shotgun") == Tables.Weapons)
@Ryanington Oh. The name of the table? If you’re getting the name of the table, try this.
local Tables = {
Weapons = {
-- PRIMARY
["Shotgun"] = "Shotgun",
-- BACKUP
["PixelGun"] = "PixelGun",
["CombatKnife"] = "CombatKnife",
-- SPECIAL
["SniperRifle"] = "SniperRifle",
-- PREMIUM
["SignalPistol"] = "SignalPistol",
}
}
local function locateTable(value)
for i,v in pairs(Tables) do
for i2,v2 in pairs(v) do
if i2 == value then -- Or v2 (I don't know what you're trying to do)
return {i,v}
end
end
end
return nil
end
print(locateTable("Shotgun")[1]) -- Prints "Weapons" | [1] = Name, [2] = Table
The title literally says Locating tables with name, so don’t blame me if the script is wrong.
The problem with this is your trying to print the dictionary, if you want to access the value (assuming they key is the same as the name of the weapon) you need to access the value in the dictionary with that key, Weapons[Weapon Name Here].