Getting the value of a dictionary thats in another dictionary?

so I have a dictionary of more dicitonarys and i want to get the “Damage” Value of the dictionarys thats inside the first one. but i cant seem to find a way to do so, ive tried returning the dictionary in a function and alot of other ways but it keeps printing nil. heres the current script please tell me if you need any more information

local LcomboRemote = game.ReplicatedStorage.LCombo

local CombatModule = require(game.ReplicatedStorage.Modules.CombatModule)

local ComboDicionary = {
	["1"] = {
		Animation = nil,
		Damage = 10
	};
	
	["2"] = {
		Animation = nil,
		Damage = 10
	};
	["3"] = {
		Animation = nil,
		Damage = 10
	};
	["4"] = {
		Animation = nil,
		Damage = 10
	};
	["5"] = {
		Animation = nil,
		Damage = 10
	};
	
}	


local UniqueCombos = {

}
local function getinfo()
	return ComboDicionary
end

LcomboRemote.OnServerEvent:Connect(function(player, ComboString, LCombo)
	for Key,Value in pairs(ComboDicionary) do
		if tostring(LCombo) == Key then
			print(Key[2])
			
			
		end
		
	end
end)

you are not fetching the value properly

Key is the iteration index within combo dictionary in pairs for loop, Value is the dictionary from index i.e ComboDictionary[Key].

Key[2] is == 1[2] assuming Key is the first index which is nil, we can also verify this would and should be nil considering the typeof() of key is a string value not a table

Instead just access the damage from “Value” table

if tostring(LCombo) == Key then
	print(Value.Damage)	
end

alternatively you can access another way like so:

ComboDictionary[Key].Damage

but you already have the table set for ease of access in Value variable

1 Like