Set the name of a table

local Items = {Exterior = {}, House = {}, Purchases = {}}

for _, v in pairs(PlayersPlot.Plot:GetDescendants()) do
		if v:IsA('BrickColorValue') then
			local ExteriorData = {}
			ExteriorData.Name = v.Parent.Name
			ExteriorData.Color = (v.Value).Name
			Items.Exterior[#Items.Exterior + 1] = ExteriorData
		end
	end

What I am trying to have it so it would look like this:

Exterior = {
    Roof = 'Black',
    Walls = 'White'
}

But it’s currently going like this

Exterior = {
    {
        Name = 'Roof',
        Color = 'Black'
    },
    {
        Name = 'Walls',
        Color = 'White'
    },
}
2 Likes

Items.Exterior[v.Parent.Name] = (v.Value).Name
will do the trick! Sorry I’m on mobile
and messed all of that up before editing it!

1 Like

It won’t tho…

for _, v in pairs(PlayersPlot.Plot:GetDescendants()) do
		if v:IsA('BrickColorValue') then
			local ExteriorData = {}
			ExteriorData.Name = v.Parent.Name
			ExteriorData.Color = (v.Value).Name
			Items.Exterior['Name'] = v.Parent.Name
			Items.Exterior['Color'] = (v.Value).Name
		end
	end


It isn’t saving all of my items

See my edit, my apologies.

mustbe30

It goes like this because #Items.Exterior is 0 since the table has no array part. You meant to use the name as a key, not the length of the table + 1