How to get tables the same name of an instance

Im trying to match the name of a table with an instance name.

-- Module script 1
local ModuleScript2 = require(game:GetService("ServerScriptService").HitBoxHandler.MeleeLibrary)
function ReturnWeaponInfo(Name)
	local weaponName = Name
   -- How do i get the table name and a specific value inside of it?
end
--Module Script 2
local MeleeLibrary = {
	["Pan"] = { -- The name im trying to get
		["Damage"] = 10, -- the value name and value im trying to get
		["StunTime"] = 1.5,
		["KnockBackForce"] = 450,
		["KnockBackUpForce"] = 500,
		["MaximumDistance"] = 4.3	
	},
	["Wooden Sword"] = { 
		["Damage"] = 12,
		["StunTime"] = 0,
		["KnockBackForce"] = 0,
		["KnockBackUpForce"] = 0,
		["MaximumDistance"] = 5.2	
	}
}

How would I be able to do this?

1 Like

Do you mean this:

-- Module script 1
local ModuleScript2 = require(game:GetService("ServerScriptService").HitBoxHandler.MeleeLibrary)
function ReturnWeaponInfo(Name)
   -- How do i get the table name and a specific value inside of it?
    local Weapon = ModuleScript2[Name]
    local Damage = weapon.Damage
    print(Name.."does"..tostring(Damage).." damage!")
end

To index values in a table, just do this:

TABLE[INDEX]

in your case, it would be:

local data = MeleeLibrary[weaponName]
print(data.Damage)

ill try it out, thank you very much

i will try it out! thank you! (Extra words)

Did it work? It should work, I just don’t know if that’s what you meant.