Quick help on how to have zero duplicates

  1. What do you want to achieve?
    I want to hav zero duplicates.
    image

6 duplicated in dis vid and i dont no how
robloxapp-20210708-1822522.wmv (2.9 MB)

heres a module dictionary table thing

local questions =
	{
		
[1] = {question = "1+1", answer = "2" }, 
[2] = {question = "2+2", answer = "4" }, 
[3] = {question = "3+3", answer = "6" },
[4] = {question = "4+4", answer = "8" },
[5] = {question = "6+6", answer = "12" },
[6] = {question = "7+7", answer = "14" },
[7] = {question = "8+8", answer = "16" }

		
	}


And heres my entire script i used for what happned in the video above

local sss = game:GetService("ReplicatedStorage")
local quest = require(sss.question) 

local QuestionText = script.Parent
local text

local parts = game.Workspace:WaitForChild("Answers"):GetChildren()


local randomAnswerTable = {}






for i = 1, 7 do -- for questions 1-7
	
	for _, v in pairs(quest) do
		table.insert(randomAnswerTable, v.answer) --insertin all answers
		print("THIS IS INSERTED"..v.answer)
	end
	
	
	local QuestionTable = quest[i]
	
	
	text = QuestionTable.question
	local length = string.len(text) --Question comes up
	
	script.Sound:Play()
	
	for i = 1, length do
		QuestionText.Text = text:sub(1, i)
		wait(0.04)
		if i > 35 then
			script.Sound:Stop()
		end
	end
	
	
	print(table.remove(randomAnswerTable, table.find(randomAnswerTable, QuestionTable.answer))) -- remove the answer the loop is on from table
	
	
	for _, v in pairs(parts) do  --for all parts

			print(QuestionTable.answer)
			
			local otheranswers = randomAnswerTable[math.random(1,#randomAnswerTable)] --random answer
			
			table.remove(randomAnswerTable, table.find(randomAnswerTable, otheranswers)) -- remove random from the table

			v.SurfaceGui.TextLabel.Text = otheranswers --text = random
				
			
	end
	
	print(QuestionTable.answer)
	local randompart = parts[math.random(1, #parts)] --Random part
	randompart.SurfaceGui.TextLabel.Text = QuestionTable.answer --the right answer on a random part
	print(QuestionTable.answer)
	
	for _, v in pairs(randomAnswerTable) do
		
		print("THIS IS DELETED"..v)
		v = nil
		
	end
	
	local therightanswer = false
	
	for _, v in pairs(parts) do
		v.Touched:Connect(function(hit)
			if hit.Parent:FindFirstChild("Humanoid") and therightanswer == false then
				if v.SurfaceGui.TextLabel.Text == QuestionTable.answer then
					
					therightanswer = true
					v.CanCollide = false
					v.Transparency = 1
					wait(2)
					v.CanCollide = true
					v.Transparency = 0.8
					
				end
			end
			
			
		end)	
	end
	
	 
	
	repeat wait() until therightanswer == true -- waiting till answer has been chosen, then next question
	
	print("YESYESYES")
	therightanswer = false
	
	
	print(QuestionTable.question .. "\n" .. QuestionTable.answer)

end


click link for Solution

If you don’t want duplicates then you should first check every answer already made i.e. if the 2nd answer part thing is being placed then check to make sure the 1st one isn’t a duplicate, and if it is, make it a random answer. An alternate solution is to put in 4 answers manually and put them in a random order

after it finished looping through all parts with the code below

for _, v in pairs(parts) do  --for all parts
wait(10)
		print(QuestionTable.answer)
			
		local otheranswers = randomAnswerTable[math.random(1,#randomAnswerTable)] --random answer
		
		if table.find(randomAnswerTable, otheranswers) then
			table.remove(randomAnswerTable, table.find(randomAnswerTable, otheranswers))
			otheranswers = randomAnswerTable[math.random(1,#randomAnswerTable)]
		end
		
		
		
		table.remove(randomAnswerTable, table.find(randomAnswerTable, otheranswers))

		v.SurfaceGui.TextLabel.Text = otheranswers
				
			
	end

this happened, how do i fix this