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 comment

1

try to print index first, just to see what it is.