# Changing lives/scores on 'Player' objects without if statements in multiplayer extension

**URL:** <https://forum.makecode.com/t/changing-lives-scores-on-player-objects-without-if-statements-in-multiplayer-extension/23675>\
**Category:** Arcade\
**Tags:** extension\
**Created:** [October 26, 2023, 5:28pm UTC](https://forum.makecode.com/t/changing-lives-scores-on-player-objects-without-if-statements-in-multiplayer-extension/23675 "2023-10-26T17:28:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![neintoes](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/neintoes/32/8315_2.png) [@neintoes](https://forum.makecode.com/u/neintoes)\
**Post date:** [October 26, 2023, 5:28pm UTC](https://forum.makecode.com/t/changing-lives-scores-on-player-objects-without-if-statements-in-multiplayer-extension/23675/1 "2023-10-26T17:28:54Z")

</div>

Below I have a simple multiplayer project with two player sprites at the top that will move to dodge snakes. I’m trying to see if it’s possible to have a single overlap event between players and enemies and if I can utilise ‘getPlayerBySprite’ in some way to get the player and use that player object to directly change that player’s lives.

so it could look something along the lines of

sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function(playerSprite, enemySprite) {  
// let _thisPlayer_ be the player attached to playerSprite  
// change the lives _thisPlayer_ by -1  
})

I’m aware I could do a few things like attach sprite data to the sprite representing the current player and use an if statement inside the overlap event and I could use different spriteKinds with different overlap events, I’m just scoping out other methods of approaching this.

Thanks for your time!

> **[multiplayer extension](https://arcade.makecode.com/67695-92870-72287-71938)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [October 26, 2023, 8:52pm UTC](https://forum.makecode.com/t/changing-lives-scores-on-player-objects-without-if-statements-in-multiplayer-extension/23675/2 "2023-10-26T20:52:35Z")

</div>

Oh ok. I think I know what you are trying to do. In my opinion, I would be much simpler to just make two separate overlap events and make a new player type to do that. Just make player 2 sprite kind food or something. Or make a new type for it.

---

<div class="post-metadata">

**Author:** ![neintoes](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/neintoes/32/8315_2.png) [@neintoes](https://forum.makecode.com/u/neintoes)\
**Post date:** [October 26, 2023, 9:12pm UTC](https://forum.makecode.com/t/changing-lives-scores-on-player-objects-without-if-statements-in-multiplayer-extension/23675/3 "2023-10-26T21:12:14Z")

</div>

I agree that would be simpler for now, but imo logically it would be neater and less repetitive to have a single ‘player’ overlap event that can interact with the different numbered players’ set/change life and score functions.
