How do you extract a value from a table, then use that as color3?

Hello, I am trying to put a players skintone inside a table, and then use it afterwards, but I cant seem to extract the value from a table. Basically whenever a player presses E, then their whole character will be the material forcefeild, and the color white. Then when they press E again, their materials turn into plastic and their skintone turns into their own original skintone, however table.concat is not working for me. Is there anything wrong with this script? Any help is appreciated, Thanks!

heres the error code when I press E again to change back to my normal state:

invalid value (userdata) at index 1 in table for ‘concat’

local color1 = {}
table.insert(color1, char.Head.BrickColor) --Skintone of player


local function Visiblity(Var)
	if Var then
		for i, Part in pairs(char:GetDescendants()) do
			if Part:IsA("BasePart") or Part:IsA("MeshPart") then
				
				Part.Material = Enum.Material.Plastic  
				char.Head.Material = Enum.Material.Plastic 
				char.HumanoidRootPart.Material = Enum.Material.Plastic 
				

				Part.BrickColor = table.concat(color1)
				char.Head.Brickcolor =  table.concat(color1)
				char.HumanoidRootPart.Brickcolor = table.concat(color1)
				
			end
		end
		
	else
		for i, Part in pairs(char:GetDescendants()) do
			if Part:IsA("BasePart") or Part:IsA("MeshPart") then
				Part.Material = Enum.Material.ForceField
				char.Head.Material = Enum.Material.ForceField 
		
				Part.BrickColor = BrickColor.new("Institutional white")
				char.Head.BrickColor = BrickColor.new("Institutional white")
			

			end
		end
		
	end
end

Instead of table.concat use

BrickColor = color1[1]

table.insert just puts the value at the end of the list if its optional index argument isn’t given.

Also table.concat returns a string with each value concatenated with its second argument.
Ex

print({1, 2, 3, 4}) -- Prints the fancy dropdown for tables

print(table.concat({1, 2, 3, 4}, ', ')) -- Prints the string: 1, 2, 3, 4,
2 Likes

Thank you so much! It worked and I learned something new thanks again