Roblox Teleport Bug

The Problem
Hi there! I’m making a round system, the problem is that only one player gets teleported and all of the other players not.

Here is my script:

local players = {}
local spawnPoints = clonedTiles:FindFirstChild("SpawnPoints"):GetChildren()
for i, player in ipairs(game.Players:GetChildren()) do
    if player then
    	table.insert(players, player)
    	if player.Character then
    	local character = player.Character
    	local randomSpawnPoint = spawnPoints[math.random(1, #spawnPoints)]
    	character:FindFirstChild("HumanoidRootPart").CFrame = +, 5, 0)
elseif not player then
   table.remove(players, i)

When copying and pasting the layout went wrong, sorry for that.

I discovered that the players does get added to the table, but they don’t teleport.

I hope you do know how to fix this, thanks for reading! :slightly_smiling_face:

Could you show any errors that are listed in dev console?

Oh, sorry, forget to note that, I didn’t got any errors.

Is the players variable the players that are in the server?

I don’t see a function that makes it execute on every existing player.

Yes. It gets all of the players and puts it in a table.

Change the ipairs loop into a pairs loop, then get the players by game.Players:GetPlayers() in the loop.

1 Like

Yeah, try that I wasn’t sure to type it correctly because of phone not supporting the lua codes.

2nd, I saw you are checking if the player has a character, But you did not end the if statement.

I found the issue, I made some mistakes in my script and found it by help of some other people, thanks for reacting!

1 Like