Table.insert inserts "void"

Making application center.

What i’m working on specifically: Answer checking; Inserting all the answers in the table in their correct order. So I can compare with the answers given by the client.

It inserts void…

local SpecificQuizAnswers = {}
for i,v in pairs(QuizAnswers["Barista Quiz"]) do
	if tonumber(i) then
		print(i,v)
		table.insert(SpecificQuizAnswers, i, v.Answer)
	end
end
print(SpecificQuizAnswers)

Relevant code.

Quiz Answers Module script

local QuizInfo = {
	["Barista Quiz"] = {
		["Requirements"] = {
			["GroupId"] = 0, --Put 0 if there is no require
			["GroupRankId"] = 0, --Will not matter if there is no groupId.
			["BlacklistedUsers"] = {"ROBLOX"}, --Username
			["BlacklistedUserIDs"] = {0, 1, 2, 3},
			["PercentageToPass"] = 75 --Out of 100. Anything above 100 will be an automatic failure
		},
		[1] = {
			["Answer"] = "A", --A,B,C, or D
		},
		[2] = {
			["Answer"] = "B",
		},
		[3] = {
			["Answer"] = "D",
		},
		[4] = {
			["Answer"] = "B",
		}
	},
	["ManagerQuiz"] = {
		["Requirements"] = {
			["GroupId"] = 0, --Put 0 if there is no require
			["GroupRankId"] = 0, --Will not matter if there is no groupId.
			["BlacklistedUsers"] = {"ROBLOX"}, --Username
			["BlacklistedUserIDs"] = {0, 1, 2, 3},
			["PercentageToPass"] = 75 --Out of 100. Anything above 100 will be an automatic failure
		},
		[1] = {
			["Answer"] = "A", --A,B,C, or D
		},
		[2] = {
			["Answer"] = "B",
		},
		[3] = {
			["Answer"] = "D",
		},
		[4] = {
			["Answer"] = "B",
		}
	},
}

return QuizInfo

If anyone can answer this, greatly appreciated.
image

2 Likes

Change this

For this

SpecificQuizAnswers[i] = v.Answer

I don’t know why void appears.

3 Likes

No clue why this works correctly, but thanks. :slight_smile:

I believe it returns void because its unable to get the value that you are looking for. Kinda like nil but it knows there is a value but failed to get it.

2 Likes

To add to the solution, when you print() out a table Roblox has internal pretty-printing formatting. When it formats the table to spit out to the console it replaces any values that are considered “unknown” with void if that makes sense.

3 Likes