I need help with table inserting

Hello I am trying to insert a table into another table but it became nested tables and I don’t want like that.

Here is my current output. These tables are nested. I don’t how to fix this.

I want a output like this:

{
["4"] = "yes"
["19"] = "no"
["10"] = "no"
["7"] = "no"
["8"] = "idk"
...
}

And this is my script(local script):

local module = require(game.ReplicatedStorage.QuestionsModule)
local list = {}

local x = Instance.new("IntValue")
x.Parent = script

local button_yes = script.Parent.QuestionFrame.AnswersFrame.yes
local button_no = script.Parent.QuestionFrame.AnswersFrame.no
local button_idk = script.Parent.QuestionFrame.AnswersFrame.idk
local button_probably = script.Parent.QuestionFrame.AnswersFrame.Probably
local button_probablynot = script.Parent.QuestionFrame.AnswersFrame["Probably not"]

local a = module.getRandomQuestion(list)

script.Parent.QuestionFrame.Question.Text = module.games[a]

button_yes.MouseButton1Up:Connect(function()
	table.insert(list, {[tonumber(a)] = "yes"})
	x.Value +=1
end)

button_no.MouseButton1Up:Connect(function()
	table.insert(list, {[tonumber(a)] = "no"})
	x.Value +=1
end)

button_idk.MouseButton1Up:Connect(function()
	table.insert(list, {[tonumber(a)] = "idk"})
	x.Value +=1
end)

button_probably.MouseButton1Up:Connect(function()
	table.insert(list, {[tonumber(a)] = "prob"})
	x.Value +=1
end)

button_probablynot.MouseButton1Up:Connect(function()
	table.insert(list, {[tonumber(a)] = "probnot"})
	x.Value +=1
end)

x.Changed:Connect(function()
	a = module.getRandomQuestion(list)

	script.Parent.QuestionFrame.Question.Text = module.games[a]

	print(list)
end)
1 Like
for i, item in tableyouwanttoinsert do
    table.insert(tabletobeinsertedinto, item)
end
2 Likes

I didn’t understand. There is only 1 item in nested tables.

1 Like

remove the {} then 30cccccccccc

2 Likes

What is 30cccccccccccccccccccc

1 Like


This error happens when i remove {}

30char minimum limit on devforum :pensive:

I misread the code mb. Is tonumber(a) unique?

1 Like

Yes tonumber(a) is uniqueeeeeeeeeee

Then do list[tonumber(a)] = “yes”

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.