local BossID = {100,200} local WorldBossHurt = { [100] = {}, [200] = {} } for i=1,10,1 do local RoleList = {nRoleID = 20000,nHurt = 40} RoleList.nRoleID = RoleList.nRoleID+i RoleList.nHurt = RoleList.nHurt+i table.insert(WorldBossHurt[100],RoleList) table.insert(WorldBossHurt[200],RoleList) print(RoleList.nRoleID,RoleList.nHurt) end for key,value in ipairs(BossID) do for key,value in ipairs(WorldBossHurt[value]) do print(key,value.nRoleID,value.nHurt) end end