Old code no longer working

I’m trying to follow an old dev tutorial, but I think Roblox ended up changing something since it no longer works from what I can tell. What it’s supposed to do I think is assign every player a number, then as soon as the game begins, teleport that player to their teleport Ie player 3 will get teleported to Part 3. Is there a modern way of doing this?


Code that doesn’t work anymore

Screenshot 2025-03-09 161335
How it’s ordered in the explorer in case it helps


Error message I get

You failed to follow the tutorial correctly. As vividly underlined, player is meant to be spelt players. The more modern and effective approach is as follows:

local Players = game:GetService("Players")
local function tryTeleportPlayers(spawnContainer: Instance)
    local players = Players:GetPlayers()
    local spawns  = spawnContainer:GetChildren()

    assert(#spawns <= #players, "Insufficient spawn opportunities.")

    for _, player in players do
        local character = player.Character
        if not character then
            continue
        end

        local spawn  = table.remove(spawns, math.random(#spawns))
        local cframe = CFrame.new(spawn.Position) 

        character:PivotTo(cframe)
    end
end
tryTeleportPlayers(workspace.GameSystem.Teleports)

change this

local players = game.Players:GetChildren()

to

local players = game.Players:GetPlayers()

also change player to players

u misspelled players[i] to player[i] (the red line), when u get an error like the one u got, it shows u which line of code contains the error, also look at red lines like the one under player[i]