Storing something in a table and then printing after prints 'nil'

So I store old properties of a BasePart to reset after, but it presents a problem:

table.insert(RoundResetInfo, {
	base,
	{
		BrickColor = base.BrickColor,
		Material = base.Material,
		Transparency = base.Transparency,
		CanCollide = base.CanCollide
	}
}) -- Storing old properties to reset

-- Printing it afterwards somewhere
print(game:GetService("HttpService"):JSONEncode(RoundResetInfo[index][2])) 
-- This prints:
{"CanCollide":true,"BrickColor":null,"Material":null,"Transparency":0.1500000059604644775390625}  -  Server - Round:197

Thank you for reading!


Both BrickColor and Material do not fit the criteria, so they will become null. You should translate them to string before converting them to JSON.

My problem is that they’re also nil in the original table, when I print:

print(RoundResetInfo[index][2].BrickColor) > nil

Meanwhile the table’s like this:

{base, {
           BrickColor = base.BrickColor,
           Material = base.Material,
           Transparency = base.Transparency,
           CanCollide = base.CanCollide
}}

It may have something to do with the key name conflicting with Roblox’s API’s default globals (BrickColor is a Roblox global and you’re using it as the key in the dictionary when it should’ve been a string)

Try something like:

{
  ['BrickColor'] = base.BrickColor
}