Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you access a dictionary?

I have a dictionary:

local Skills = {
	["IP"] = 1,
	["virus"] = 1,
	["firewall"] = 1,
	["trace"] = 1,
	["network"] = 1,
	["remote"] = 1,
	["physical"] = 1,
	["stealth"] = 1,
	["local"] = 1,
	["cracker"] = 1,
	["level"] = 1
}	

but how do I access it?

2 comments

0

Access in what way? What information do you want to store / retrieve?

0

Well I want to be able to access it by string/name and be able to change the values

1 answer

✓ Accepted answer

If you're talking about accessing the information inside the dictionary, then you just index the table using a dot . or square brackets [ ]. I'm not gonna go into crazy detail about it, so I'll just leave you with these examples, as they're pretty easy to pick up:

local Skills = {
    ["IP"] = 1,
    ["virus"] = 1,
    ["firewall"] = 1,
    ["trace"] = 1,
    ["network"] = 1,
    ["remote"] = 1,
    ["physical"] = 1,
    ["stealth"] = 1,
    ["local"] = 1,
    ["cracker"] = 1,
    ["level"] = 1
}   

print(Skills["IP"]) -- Prints the value Skills.IP represents 
print(Skills.IP) -- this works too (because the key follows the same rules variables obide by)

Skills.IP = 5 -- To change the key, simply set it a new value.

If you're confused about any of this, let me know. Sorry this couldn't be one of my long answers, I just didn't have the time.

This discussion is preserved as it was. New answers, comments, and votes are closed.