-- this isn't local. in some extreme cases (two or more players death at same time) - it can go crazy.
player = xmlFindChild(xmlFile, "skin", playerSkin-1)
-- also be sure if playerSkin have valid value.
-- maybe it's nil or something?
-- try:
outputDebugString("player skin from element data: "..tostring(playerSkin))
-- put this before this line
-- check(source)
-- and put this:
outputDebugString("child found: "..tostring(player))
-- just after line with xmlFindChild
--
-- you can also put this
outputDebugString("doing this for player: "..getPlayerName(source))
-- on function beginning