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

Inserting A Table Into A Dictonary?

Hello Guys, Thank You For Clicking On My Question. As The Title Says, I've Been Searching How To Iterate Through A Table Tha's Into A Dictionary. I Know It's Possible Because I've Seen People Who Used This (The Owner Of Anime Fighting Simulator, For Example). So, I Tried Iterating With A For Loop, But It Was Kinda Weird And I Didn't Get What I Wanted.

So, If You Know How To Make So That You Can Iterate Through The Table That's Into The Dictionary, I Would Really Appreciate If You Put It Down In The Comments Section.

Example Of What I'm Trying To Do:

SabersConfig.Info = {
	 ["A"] = {
		['Name'] = 'Force Push';
		['Power'] = ForcePush(); --That's A Function
		['Key'] = "F";
		}	
}

5 comments

0

:/

0

52 views... :/

0

I'm confused. Are you trying to iterate or insert?

0

I'm trying to iterate through the Dictonary and get to the values like Name, Power And Key.

0

This is so sad :/

1 answer

✓ Accepted answer

There are a couple of ways to iterate through a table.

The first way is a numerical for loop.

local Array = {1,2,3}

for i = 1, #Array do
	print(Array[i])
end

The other way is to use a pairs loop.

local Dictionary = {
	A = "B",
	C = "D",
}

for i,v in pairs(Dictionary) do
	print(i, v)
end

3 comments

0

Uh, I think you misunderstood me. What I was looking for ways to Iterate through a table that's into a Dictionary, As the example shown above.

0

You'd do the same thing I just did inside another for loop with the other table you want.

0

Oh, Right. Thank You So Much!

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