How do I use a loop to find individual data in a dictionary?

How do I use a loop to find data in a dictionary?
I want to get the string or value of the data however it appears as nil.

	local ObjectData = {
		["Unit"] = {
			["ObjectName"] = "Item",
			["ObjectID"] = HttpService:GenerateGUID(false),
			["desc"] = "Desc",
			["Level"] = 1,
			["Experience"] = 0,
			["Artifact"] = "None",
			["Favourite"] = false,
		}}

		for i, x in pairs(ObjectData) do
        print(x[1])
        print(x[2])
		end

You can’t use integer indices/indexes in a dictionary. You must use the key name. What I mean:

That only works for arrays and not dictionaries, for a dictionary you must do:
x["ObjectName"]

1 Like