Ad
Log in to vote
0

Bad Argument #1 to 'remove'(table expected, got nil) Does anyone know how to fix this?[SOLVED]

Asked by 1 year ago
Edited 1 year ago

Dont worry about it, I figured out I put a period there instead of a comma XD

The script teleports players and as it is teleporting them it removes the spawn they landed on so people dont teleport on top of them or so no 2 people land on the same spawn. But I get an error?

Does anyone know how to fix it. Here the code :)

    local spawns = chosemap:WaitForChild("Spawns"):GetChildren()
    for _, player in pairs(game.Players:GetPlayers()) do 
        if player and #spawns > 0 then
            local uppertorso = player.Character:WaitForChild("UpperTorso")
            local allspawns = math.random(1, #spawns)
            local randomspawns = spawns[allspawns]
            if randomspawns and uppertorso then
                table.remove(spawns.allspawns)
                uppertorso.CFrame = CFrame.new(randomspawns.Position + Vector3.new(0, 3, 0))
            end
        end
    end

Thank you for your time

Answer this question