Get value name from dictionary?

Looking to create values based on the content of a dictionary.

local dictionary = {
	["Content1"] = "Hello",
	["Content2"] = 50,
	["Content3"] = "Bonjour"
}

for w, item in pairs(dictionary) do
		print(item)
		if tonumber(item) ~= nil then
			local val = Instance.new("IntValue", dataFolder)
			val.Name = dictionary[item]
			val.Value = item
		else
			local val = Instance.new("StringValue", dataFolder)
			val.Name = dictionary[item]
			val.Value = item
		end
end

How can I name the values “Content1” rather than the value of “Hello”?

1 Like

Just use your variable w? It is the key in the key-value pair your current iteration is on.

6 Likes

dictionary[w] returns the value.

1 Like

Where did I say to do dictionary[w]? Just use w.

print(w).

1 Like

Oh! Thank you very much. :smiley:

1 Like