Failed attempt to set up UI in the Advanced Tutorial (multiplayer shooter)

I've been trying to set up some UI in the Advanced Tutorial. I want to display a public Text mesh that would show how many times each player gets shot. This is a youtube tutorial I've tried to use:

So basically in the Level2 scene I've set up a Canvas with a TextMeshProUI for the hit(getting shot) count. Canvas has this script attached to it:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class GameCanvas : Bolt.GlobalEventListener
    public TextMeshProUGUI scorePopup;

    public override void OnEvent(ScoreEvent evnt)
        scorePopup.text = evnt.Message;

Here I have my ScoreEvent(I know it's technically not a score, but I left the name after following the youtube tutorial):

I've created a new PlayerDataForDisplay script for the data about players that I want to be shown in the screen:
public class PlayerDataForDisplay : Bolt.EntityBehaviour<ITutorialPlayerState>
    public int hitsTaken = 0;

    public void ChangeHitsTaken()

        var scoreEvent = ScoreEvent.Create();
        scoreEvent.Message = PlayerPrefs.GetString("username") + " got hit " + hitsTaken + " times";

Then in the TutorialWeaponRifle script at the end of if (Physics.Raycast(r, out rh) && impactPrefab) statement I added this piece of code (playerDataForDisplay is initialized like so: private PlayerDataForDisplay playerDataForDisplay;):
if (rh.collider.CompareTag("Player"))
I added the "Player" tag and a collider to the player(just in case I added those to the mesh as well).
Also the PlayerDataForDisplay script is attached to the player as well.

Then I build and run the Level2. Everything is fine until I shoot another player(both from server and from client view). Everything stops and this is what's showing:

The editor log throws a NullReferenceException at the part of the code I added to TutorialWeaponRifle. I guess it's expected but I'm not sure how to proceed. Help is much appreciated! :'(

Sign In or Register to comment.