Value not inserting into an array

  1. What do you want to achieve?
    I want to insert a value (in this case, a name) into an array.

  2. What is the issue?
    I want to insert the name into the “Chosen” array, but it gives me a nil print.

local Chosen = {}
local Number = 1

for i, v in pairs(Morphs:GetDescendants()) do
	if v:FindFirstChild("CameraV") and v:FindFirstChild("Morph") then
		print(v.Name)
		--Chosen[Number] = v.Name
		table.insert(Chosen, v.Name)
		Vueltas += 1
		print(Chosen[Number])
	end
end

Can you print the whole table afterwards instead of table[Number] to verify that it’s not just that index that’s nil. As far as I can tell, this code alone shouldn’t have any issues unless it never entered the if statement or loop.

my other answer was based on me misreading something, so it was nonsensical.

1 Like

So it plints the whole array, but it returns a nil value when I try to get it with a number as

Chosen[Number]

Nevermind, found the glitch.

It was just in an error in my other part of the code.

1 Like