Updating the scoreboard when hit

Could anyone please help with the code for the game?

What I want to do is have the (playable) character have an effect on the score whenever he gets hit with arrows that are coming at him (an animation that I had made). I already have a score counter ready as well.

What code should I use to accomplish this?

Do you need to detect when the character is hit or you dont know how to increase/decrease the counter?

Both, actually. Mr. Evgenii is my teacher, and he asked this question on my behalf, so I will be the one responding.

When the character “hits” the arrow, I want the score counter to change. I tried to use the if (hits) command, but I wasn’t able to understand how it works. The original was:

if (this.hits(that)) {
//Do Something!
}

And the way I did this was:

if (mainCharacter.hits(arrow)) {
//project.score += 1;
}

And yet, it just says error for me and doesn’t let me play. The playable character is titled as “mainCharacter”, and the obstacles coming at the playable character are called “arrows”. If there is anything I’m doing wrong, I would be really grateful for you to point out what.

Also, if it isn’t too much trouble, if you do find out a code that works, will you be able to send it to this thread? If there are any more clarifications, I’m ready to respond as soon as possible.

Here is something similar that could help you to understand the concept…

Tutorial

https://www.youtube.com/watch?v=6VnJptZIo8A

Jovanny tutorial contains all you need but here is a condensed version specific for your case
playerHitByArrow.wick (3.2 KB)

Mind that if you have more then one arrow (very likely) you have to adopt a strategy to check all of them
There can be different solutions depending on your game structure

Alright, thank you very much!