-- Color tables
colors = {"blue", "red", "orange", "green"}
--table = {light color, dark color}
blue = {"Pastel Blue", "Cyan"} red = {"Persimmon", "Really Red"} orange = {"Gold", "Deep orange"} green = {"Shamrock", "Lime green"}

-- Changes tycoon template colors
local spawns = game.workspace.Tycoon_Spawns:GetChildren()
game.workspace.Tycoons.ChildAdded:connect(function(child)
	local value = child:GetDescendants()
	local random_color = math.random(1, #colors)
	local ran_color = colors[random_color]
	local str = Instance.new("StringValue", child)
	str.Name = "Tycoon_Color"
	str.Value = ran_color
	table.remove(colors, random_color)
	for i = 1, #value do
		local color = child.Tycoon_Color.Value
		print(color)
		if value[i].Name == "light" then
			print(color[1])
		end
		if value[i].Name == "dark" then
			print(color[2])
		end
	end
end)

3 comments

0

Your going to have to give more info then that...

0

like itll pick a random color name and call that table like color[1] and ittl call blue[1] or red[1] but instead it just goes nil

0

Learn about dictionaries / associative arrays. Have a table of tables, indexed by "blue", "red", etc. Look up the required table with subTable = superTable[colourName].