Here is my code:
hit_list = pygame.sprite.groupcollide(all_bats, all_sword, False, True, collided = pygame.sprite.collide_mask(bat_front1, sword1))
for self in hit_list:
self.bat_health -= 1
if self.bat_health == 0:
self.kill()
bat_front is the image I am using for the enemies in all_bats, and sword1 is the image I am using for the enemies in all_sword. This code is in the update section of my bat class. When I run the code I get the error message 'pygame.Surface' object has no attribute 'rect' and the line xoffset = right.rect[0] - left.rect[0] is highlighted from sprite.py. I get no error when I don't use a collided function but the hit collision is pretty bad. I have no clue why I get the error message :/