I’m trying to add a piece of data into a core table that stores all of a players stuff. This is the code
local Items = {Exterior = {}, Interior = {}, Landscape = {}, Furniture = {}}
-- Get the floor and wall textures
for _, room in pairs(PlayersInterior.Build.InteriorElements:GetChildren()) do
-- Save the floor and wall for each individual room number
print(room.Floor) -- prints 'Floor'
Items.Interior[room.Name].Floor = string.match(room.Floor.Texture.Texture, '%d+') -- ERROR HERE
Items.Interior[room.Name].Walls = string.match(room.Wall.Texture.Texture, '%d+')
end
And I get this error
[attempt to index nil with ‘Floor’]
For this line
Items.Interior[room.Name].Floor = string.match(room.Floor.Texture.Texture, '%d+') -- ERROR HERE
Now I know room and room.Floor are their (not nil) so I’m assuming it has to do with this part
Items.Interior[room.Name].Floor
And if that’s the case how can I fix this? My intention is that line would turn this ‘Items’ table to look like so
local Items = {
Exterior = {},
Interior = {
['1'] = {Floor = 1234, Walls = 1234},
['2'] = {Floor = 1234, Walls = 1234},
['3'] = {Floor = 1234, Walls = 1234},
},
Landscape = {},
Furniture = {}
}
‘rooms’ is basically a numbered folder which contains all the parts