Why isnt my "Value" variable updating every time the script is run?

Im trying to make a script that gets a table “requests” that contains various user id’s that im trying to get to add a player to a waiting queue. When i add more than 2 people to the queue the script gives an error:

Players.DisastrousFate.PlayerGui.OutfitQueue.LocalScript:21: attempt to index nil with ‘Destroy’

I think the cause is that my value variable isnt updating when run. Why is this?

Edit: I think the issue is that the in pairs loop is messing it up. how do i fix it

Code:

local players = {}
game.ReplicatedStorage.GetQueue.OnClientEvent:Connect(function(requests, currentid, targetusername, isrunning)
	for _,v in pairs(requests) do
		
	
		table.insert(players, v)
		print(table.find(players, v))
		local clone = game.ReplicatedStorage.QueueExample:Clone()
		
		clone.Name = v
		local text = v
		clone.Username.Text = v
		clone.Parent = script.Parent.Frame.Frame.Folder
		--======MAIN=======
		for index,value in pairs(players) do
			print("here!")
			if players[table.find(players, v)] ~=  value then --1, 1231231, 2, 132123213
				print("NO!")
				print(players[table.find(players, v)], "old: "..value) ---VALUE NOT UPDATING. CAUSING ERROR WHEN CALLED MORE THAN 2 TIMES
				table.remove(players, value)
				script.Parent.Frame.Frame.Folder:FindFirstChild(value):Destroy()
				
			end
		end
		--======MAIN======================
	end
end)

Game file: System Copy.rbxl (54.3 KB)

Does it print this line?

print("here!")

Yes, it does print “here” every time, ive also added a game file in the post if you want to use it for testing

for index,value in pairs(players) do
      print(value)
end

What does this code print when u put it in?

It prints the same value each time.

Print the table players…(char limit)

Ive made progress on figuring out the script.

game.ReplicatedStorage.GetQueue.OnClientEvent:Connect(function(requests, currentid, targetusername, isrunning)
	for _,v in pairs(requests) do
		local players = {}
		print(requests)
		table.insert(players, v)
		print(table.find(players, v))
		local clone = game.ReplicatedStorage.QueueExample:Clone()
		
		clone.Name = v
		local text = v
		clone.Username.Text = v
		clone.Parent = script.Parent.Frame.Frame.Folder
		print(players)
		--======MAIN=======
		for index,value in pairs(players) do
			print("Value : "..value)
			print("here!")
			if players[table.find(requests, value)] ~=  value then --1, 1231231, 2, 132123213 -- 247535, 247535 OR 
				print("NO!")
				print(players[table.find(requests, players)], "old: "..value) ---VALUE NOT UPDATING. CAUSING ERROR WHEN CALLED MORE THAN 2 TIMES
				
				
			else
				return
			end
			table.remove(players, value)
			script.Parent.Frame.Frame.Folder:FindFirstChild(value):Destroy()
			print(players, value)
			value = nil
		end
		--======MAIN======================
	end
end)

How abt putting the second for loop separately in the script?

Small optimisation tip for you

players[Player] = value

if players[Player] ~= value then
  ...
end

as for your code, i dont have enough information to debug it