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

How do i call on a value in an index in a dictionary?

-- Color table
colors = 
{
	[0] = {"blue", "Pastel Blue", "Cyan"}; 
	[1] = {"red", "Persimmon", "Really Red"};
	[2] = {"orange", "Gold", "Deep orange"};
	[3] = {"green", "Shamrock", "Lime green"}
}
-- Changes tycoon template colors
game.workspace.Tycoons.ChildAdded:connect(function(child)
	local tycoons = child.Parent:GetChildren()
	local children = child:GetDescendants()
	local str = Instance.new("StringValue", child)
	str.Name = "Tycoon_Color"
	str.Value = 1
	table.remove(colors, #tycoons - 1)
	for i = 1, #children do
		
		if children[i].Name == "light" then
			print(colors[child.Tycoon_Color.Value[1]])
		end
		if children[i].Name == "dark" then
		end
	end
end)

-- Clones tycoon template to tycoon spawns
local spawns = game.workspace.Tycoon_Spawns:GetChildren()
for i = 1, #spawns do
	local picked = spawns[i]
	local clone = game.workspace.Test_Tycoon:Clone()
	clone.Parent = game.workspace.Tycoons
	clone:SetPrimaryPartCFrame(CFrame.new(picked.Position))
	clone:SetPrimaryPartCFrame(clone:GetPrimaryPartCFrame() * CFrame.Angles(0, math.rad(picked.Orientation.y), 0))
	picked:Destroy()
	if i == #spawns then
		game.workspace.Tycoon_Spawns:Destroy()
	end
end

3 comments

0

I am trying to call 1 of the 2 values in the indexs

0

dude we need more info

0

im literally just trying to call a value from an index in a table do i gotta spell it out for u greatneil80

1 answer

To grab information for an Array or Dictionary you need to give the script the array or dictionary name and the key. For your case, if I wanted to grab the first row of information I would type local Variable = colors[0]. That should give you the string of the blue colors. If you need more help here is a link to the Roblox Developer page explaining the basics of Tables, Arrays, and Dictionaries: Roblox Developer - Tables

1 comment

0

ye ik that but how do i pick a variable in the 0 table

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