Player Kill Detector

I have spent the entire day tryna figure this out and I need some help and if you want I can PayPal you or whatever you a few dollars if you can help me out. I can send you a few my scripts for shooting but I just cannot figure out how to do this.

Script for shooting the gun: using System.Collections;using System.Collections.Generic;using UnityEngine; - Pastebin.com

Script that get spawned on every bullet that gets spawned:

Script that deals with player health and hopefully kills:

So you can take a look through my code. I just commented it so it should be fairly easy to understand my messy code but on the KillHealthManager script I want to make it so it detects who shot them. On line 49 is where I detect if the player got hit and what I want you to do is try to make it so it also tells who hit the player and then tell that player who hit them to increase their kill count variable by one if this makes sense. I provided the scripts I am using for shooting the gun, and the script that is on the bullet if you want to take a look at those. Thank you so much if you can help me and if not that is totally okay!

I don’t think it’s a good solution but you can transfer information about who shot in the bullet, and then add one to his kill value on the server on hit.
Something like this:
Bullet code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
using Unity.Netcode;
using System;

public class Projectile : NetworkBehaviour
{

    //The speed of the projectile
    public float projectileSpeed = 150;

    //The size the projectile should be
    public float scale = 0.35f;

    //the id of the shooter
    public NetworkVariable<ulong> shooterId = new NetworkVariable<ulong>();

    //The game object for the projectile that spawns.
    public GameObject projectile;

    // Destroys the bullet if it runs into a wall or something that isint a player.
    void OnTriggerEnter(Collider collider)
    {
        if (IsServer)
        {
            if (collider.gameObject.tag == "Untagged")
            {
                Destroy(projectile);
            }
        }
    }


    [ServerRpc (RequireOwnership = false)]
    public void AddKillsServerRPC()
    {
        KillHealthManager[] list = GameObject.FindObjectsOfType<KillHealthManager>();
        for (int i = 0; i < list.Length; i++)
        {
            if(list[i].id.Value == shooterId)
            {
                list[i].kills++;
            }
        }
    }

    public override void OnNetworkSpawn()
    {

        base.OnNetworkSpawn();

        //Sets the projectiles speed on network spawn.
        GetComponent<Rigidbody>().velocity = this.transform.forward * projectileSpeed;

        //Sets the scale of the projectile to the projectile scale.
        projectile.gameObject.transform.localScale = new Vector3(scale, scale, scale);
    }
}

KillHealthManager code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
using Unity.Netcode;
using System;
using TMPro;

public class KillHealthManager : NetworkBehaviour
{

    // Max amount of health for each player
    public int maxHealth = 120;

    // Range of the map for the player to spawn in
    [SerializeField] private float positionRange = 70f;

    // How many kills a player needs to win the game
    public int killsToWin = 20;

    //the id of the player:
    public NetworkVariable<ulong> id = new NetworkVariable<ulong>();

    //only the server keeps track of the kills
    public int kills;

    // Textbox for the text that shows who won the round
    public TMP_Text winText;

    // Keeps track of how many kills this player has
    private int playerKills = 0;

    // The name of the player
    private string playerName;

    private void Update()
    {
        CheckHealth();
    }

    public override void OnNetworkSpawn()
    {
        base.OnNetworkSpawn();
        applyIdServerRPC(NetworkManager.Singleton.LocalClientId);
    }

    [ServerRpc (RequireOwnership = false)]
    public void applyIdServerRPC(ulong _id)
    {
        id.Value = _id;
    }

    // Just checks the players health and kills them if its 0 or below
    public void CheckHealth()
    {
        if (health.Value <= 0)
        {
            Die();
        }
    }

    // This is the health variable that is synced across the network
    [HideInInspector]
    public NetworkVariable<int> health = new NetworkVariable<int>(
        value: 120,
        NetworkVariableReadPermission.Everyone,
        NetworkVariableWritePermission.Owner);

    public void OnTriggerEnter(Collider collider)
    {
        //Checks if the player has been hit by a object and checks if that object had the script projectile, signifying they have been hit by a bullet and will now be subracted 15 health.
        if (collider.GetComponent<Projectile>())
        {
            Debug.Log("Player Hit");

            // Negates their health by 15.
            health.Value -= 15;
        }
    }

    // The script that gets called when a player dies/health is under 0.
    void Die()
    {
        //When a players health is 0 or under, this script will run which resets their health and teleports them to a random position
        transform.position = new Vector3(Random.Range(positionRange, -positionRange), 0, Random.Range(positionRange, -positionRange));
        Debug.Log("Player Died");
        health.Value = 120;
    }

    private void Start()
    {
        if(NetworkManager.Singleton.IsServer)
        {
            kills = 0;
        }

        // This is just a service I am using to keep track of player names and the items they own. Dont worry about this. All its doing is getting the player name from Loot Locker and setting it as the player name variable.
        LootLockerSDKManager.GetPlayerName((response) =>
        {
            if (response.success)
            {
                Debug.Log("Successfully retrieved player name: " + response.name);
                playerName = response.name;
            }
            else
            {
                Debug.Log("Error getting player name");
            }
        });
    }
}

Gun code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
using Unity.Netcode;
using System;
using TMPro;

public class Gun : NetworkBehaviour
{

    // How often you can shoot the gun
    public float fireRate = 15f;

    // The prefab of the bullet
    public GameObject projectile;

    // The position of the bullet
    private Vector3 destination;

    // Where the bullet gets spawned from
    [SerializeField] private Transform InistialTransform;

    // All of these should be pretty self explanitory
    public int maxAmmo = 15;
    private int currentAmmo;
    public float reloadTime = 1f;
    private bool isReloading = false;

    //The camera that the player sees through and the impact effect when the bullet hits something.
    public Camera fpsCam;
    public GameObject impactEffect;

    // The animator for reloading
    public Animator animator;

    // Keeps track of when the player can shoot next
    private float nextTimeToFire = 0f;

    // Makes sure that they start with a full mag.
    private void Start()
    {
        currentAmmo = maxAmmo;
    }

    // Makes sure they dont start reloading.
    void OnEnable()
    {
        isReloading = false;
        animator.SetBool("Reloading", false);
    }

    // Checks some player stuff.
    void Update()
    {
        if (isReloading)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.R) && IsOwner)
        {
            StartCoroutine(Reload());
            return;
        }

        if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire && IsOwner)
        {
            nextTimeToFire = Time.time + 1f / fireRate;
            if (currentAmmo > -1)
            {
                Shoot();
            }
        }
    }

    // Reloads the gun
    IEnumerator Reload()
    {
        isReloading = true;
        Debug.Log("Reloading...");

        animator.SetBool("Reloading", true);

        yield return new WaitForSeconds(reloadTime - .25f);
        animator.SetBool("Reloading", false);
        yield return new WaitForSeconds(1f);


        currentAmmo = maxAmmo;
        isReloading = false;
    }

    // Shoots the gun
    void Shoot()
    {
        currentAmmo--;

        RaycastHit hit;
        if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit))
        {
            Debug.Log(hit.transform.name);

            ShootProjectile();

            GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
            Destroy(impactGO, 2f);
        }
    }

    // Starts the instantiating bullet process.
    void ShootProjectile()
    {
        Ray ray = fpsCam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            destination = hit.point;

        }
        else
        {
            destination = ray.GetPoint(1000);
        }

        //Starts the instantiating bullet process.
        SpawnBulletServerRPC(InistialTransform.position, InistialTransform.rotation, NetworkManager.Singleton.LocalClientId);
    }

    // This actually instantiates and spawns the bullet where I want.
    [ServerRpc]
    private void SpawnBulletServerRPC(Vector3 position, Quaternion rotation, ulong id, ServerRpcParams serverRpcParams = default)
    {
        //Instantiates the bullet
        GameObject InstantiatedBullet = Instantiate(projectile, position, rotation);

        //Spawns the bullet through the network
        InstantiatedBullet.GetComponent<NetworkObject>().Spawn();
        StartCoroutine(addId(InstantiatedBullet, id));
    }

    public IEnumerator addId(GameObject bullet, ulong id)
    {
        yield return new WaitUntil(() => bullet.GetComponent<NetworkObject>().IsSpawned );
        bullet.GetComponent<Projectile>().shooterId.Value = id;
    }
}

Tysm! Il try this code once I am able to in a few hours. Thanks!