Can't unpack this nested table

Hello.

I am getting this error…
image
… in this local script (cut because I don’t want to reveal too much)

local config = {

	["Ruins"] = {
		color = {254, 173, 242}, fog = {1000, 1000}
	},
	
}

local function ChangeFog(thing)
	game.Lighting.FogColor = Color3.fromRGB(unpack(config[thing.Name][1])) -- line in question
	game.Lighting.FogEnd = config[thing.Name][2][1]
	game.Lighting.FogStart = config[thing.Name][2][2]
end

Am I using unpack correctly? I don’t really know what’s causing it to get nil.

print out thing
because thing.Name is nil

thing.Name should equal to “Ruins”

That’s because the index is not a number and you try to index it with 1.
This is how you should do it

unpack(config["Ruins"].color)
1 Like