Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

I don't know how to fix this error. How do I fix it?

Asked by 9 years ago

I made a script for my game, but I got an error. Also, every time when the round is over, I don't get spawned in the lobby. This is my script:

    --teleport plays back to lobby
    local lobbyspawns = {}
    for _, v in pairs(game.Workspace:WaitForChild("Lobby"):GetChildren()) do
        if v and v.Name == "SpawnLocation" then
            table.insert(lobbyspawns, v)
        end
    end
    for _, player in pairs(activecontestants) do
        if player then
            awardpoints(player, 1)
            if player.Character then
                local humanoid = player.Character:FindFirstChild("Humanoid")
                if humanoid then
                    humanoid:UnequipTools()
                end
            end

            local randomspawn = lobbyspawns[math.random(1, #lobbyspawns)]
            player.Character:MoveTo(randomspawn.Position)

            local backpack = player:FindFirstChild("Backpack")
            if backpack then
                backpack:ClearAllChildren()
            end
        end
    end
    killer = nil
    sheriff = nil

This is the error (AGAIN)

10:48:41.721 - ServerScriptService.MainScript:458: bad argument #2 to 'random' (interval is empty)
10:48:41.723 - Script 'ServerScriptService.MainScript', Line 458
10:48:41.725 - Stack End
1
Which is line 458? TheStudentPilot 75 — 9y
0
Line 18 User#5689 -1 — 9y
0
What you can do, is everywhere you would get a value (such as a number), add a print to see what you get. That could limit the possibilities of the problem. If something prints nil or errors, let me know. TheStudentPilot 75 — 9y
0
I either messed it up or it did the same. User#5689 -1 — 9y

Answer this question