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

Insert Values Into Dictionary?

What I need to be able to do is get the children of an object and create/insert into a dictionary. For example, I want the end dictionary to be like...

Thing1Name = {
[thing1child] = thing1.Value
[thing1child2] = thing2.Value
}

1 answer

This is the general format for adding to a dictionary:

myDictonary[key] = value

if you wanted to add an an item to Thing1Name with the key "Part" and the value game.Workspace.Part, then you'd say:

Thing1Name["Part"] = game.Workspace.Part

I'm guessing you're trying to save a bunch of object values into a dictionary.

Let's say we had a setup like this in the workspace.

to put all those values into a table we'd say:

local myDictionary = {}

for _, child in pairs(game.Workspace.Data:GetChildren())do
	myDictionary[child.Name] = child.Value 
end

1 comment

0

You alright?

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