The Last Player In A Table Does Not Get Teleported

It’s skipping some players in the list because you are making the list shorter while looping through the same list.

local t = {"A","B","C","D","E"} 
for i,v in pairs(t) do 
	if v == "C" then 
		table.remove(t, i) 
	end 
	print(i,v) 
end

Output:

1 A
2 B
3 C
4 E

See how there was 5 entries, but it only prints 4 times?

What you need to do is instead of removing players from the list, to simply just teleport as you go down the list

if character then
	character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[i].CFrame
	game.ReplicatedStorage.WaitScreenEnd:FireClient(player)
end
1 Like