Void showing up in table

when I print the output of playerVotes (which is a table) void appears as one or more of the values in my table and I’m not sure why because I only change the values of the table with + and - 1

voteEvent.OnServerEvent:Connect(function(player, vote, previousVote)
	--print("player "..player.Name.." has voted for map "..vote)
	print(vote)
	if playersVotes[vote] then
		playersVotes[vote] = playersVotes[vote] + 1
	else
		playersVotes[vote] = 1
	end
	
	if previousVote then
		print(previousVote)
		playersVotes[previousVote] = playersVotes[previousVote] - 1
	end
	
	print(playersVotes)
end)

same problem cant resolve the issue

Are all the playerVotes 0 by default?

Void appears when there are missing indexes in an array.

e.g.

1 = 123
2 = 34
3 = nil
4 = nil
5 = 456
7 = nil
8 = 56
9 = nil
10 = nil

It returns

1 = 123
2 = 34
3 = Void
4 = Void
5 = 456
7 = Void
8 = 56
-- 9 and 10 do not show up because lua has no way of knowing if they exist.
1 Like