Score added on collision with another player

Hi guys, so I’ve got this very simple game going, and I guess for me to be able to ask the question I gotta give a bit of context. The game works by having a player made up of two parts, a front and a back (pictured)

And attached to that back square, is the following code, which means that if something collides with it, the player is destroyed

Now, heres the issue, that I cant for the life of me come up with a solution for. The game is Multiplayer, and all the players have this. I want to make it so when the front square hits the back square of another player (destroying the other player), the player that hit the player gets a point. Even better if you can tell me how to display this.

Thanks a lot guys, hopefully there will be an easy answer to this, but I just dont know what to do.

OK in the OnTriggerEnter you get the collider from this you can get the gameObject that collided and the Unit/Player script that will gain the points.

So in OnTriggerEnter you will have a line like this…

other.gameObject.GetComponent<Player>().AddScore(100);

Note just off the top of my head so you should check the docs to ensure you use the correct properties and methods.

Also none player game objects could trigger this so you should really do this

Player player = other.gameObject.GetComponent<Player>();

if (player) player.AddScore(1000);

Thanks mate, but Im having a little trouble understanding what this means, and how to implement it into my script, and I guess what to do from there to make it show as a gui text
Sorry I dont specialise in coding, but I try