How do I insert something into a dictionary?

Is it possible to insert something like this into a dictionary?

Player1 = 500

For example if I made an empty dictionary, how do I add a value?

local dictionary = {}
table.insert(dictionary, ???????)
1 Like

You can do that like this:

local dictionary = {}

dictionary["SomethingHere"] = 999

-- some more examples
dictionary[`{player.UserId}_weapons`] = {}
dictionary[3] = "hello"

You need to index the dictionary with [], give the name, and then you can set it, or just index it like dictionary.something.

1 Like
local dictionary = {}

dictionary.newTable = {1, 6, 4}

--[[
dictionary = {
   newTable = {1, 6, 4}
}
]]--
2 Likes

This worked! Thank you a lot!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.