Table.unpack not working as expected

So I’m sending data to add to a custom leaderboard, which every player has.
The problem is that its giving out a nil on the client.

Server:

	if Data ~= nil then
		local datatoSend = {
			['Username'] = player.Name,
			['Coins'] = Data.Coins,
			['Rebirths'] = Data.Rebirths,
			['level'] = Data.Level,
		}
		server.fireallclients(7, datatoSend) -- to add to leaderboard
	end

client:

		events.RemoteEvent.OnClientEvent:Connect(function(atype, data)
			print('updating leaderboard!')
			if atype == 7 then
				local playerName, coins, rebirths, level = table.unpack(data)
              	print(playerName)				
			end
		end)

table.unpack() doesn’t work with dictionaries. Can’t you just index data.Username to get the player’s name?

2 Likes

There’s not much point in declaring additional variables when you can just index the dictionary’s keys/fields.