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

Why is the index in a for loop returning a string?

Asked by
Azmidium 388 Moderation Voter
9 years ago

I am fixing up a for loop that puts all the players winnings from the previous game in a table. I do this to get the player that got the most points in the previous game.

This is the code:

for index, child in pairs (PlayersInGame) do
        if index ~= nil then
            table.insert(playerScores, index, child:WaitForChild("invisstats").Stats.Value)
        end
    end

The error I am getting is:

Workspace.GameRunner:180: bad argument #2 to 'insert' (number expected, got string)

Why is a freaking index in a loop returning string?

Sincerely,

jmanrock123

P.S. Thanks to whoever tried helping me.

1
try to print index first, just to see what it is. LegitimatlyMe 519 — 9y

Answer this question