fix this errors:
NullReferenceException: Object reference not set to an instance of an object
MarsFPSKit.Weapons.Kit_ModernWeaponScriptRuntimeData.FiredWeapon (MarsFPSKit.Kit_PlayerBehaviour target, System.Int32 damageIndex, UnityEngine.Vector3 originPoint, UnityEngine.Vector3 hitPoint) (at Assets/314 Arts/MarsFPSKit/Scripts/Player/Weapons/Kit_ModernWeaponScriptRuntimeData.cs:383)
MarsFPSKit.Weapons.Kit_ModernWeaponScript.FireRaycast (MarsFPSKit.Kit_PlayerBehaviour pb, MarsFPSKit.Weapons.Kit_ModernWeaponScriptRuntimeData data, System.Single delta, System.Single revertBy) (at Assets/314 Arts/MarsFPSKit/Scripts/Player/Weapons/Kit_ModernWeaponScript.cs:3930)
MarsFPSKit.Weapons.Kit_ModernWeaponScript.FireOneShot (MarsFPSKit.Kit_PlayerBehaviour pb, MarsFPSKit.Weapons.Kit_ModernWeaponScriptRuntimeData data, System.Single delta, System.Single revertBy, System.Boolean rpc) (at Assets/314 Arts/MarsFPSKit/Scripts/Player/Weapons/Kit_ModernWeaponScript.cs:3827)
MarsFPSKit.Weapons.Kit_ModernWeaponScript.AuthorativeInput (MarsFPSKit.Kit_PlayerBehaviour pb, MarsFPSKit.Weapons.Kit_WeaponRuntimeDataBase runtimeData, MarsFPSKit.Kit_PlayerInput input, System.Single delta, System.Double revertTime) (at Assets/314 Arts/MarsFPSKit/Scripts/Player/Weapons/Kit_ModernWeaponScript.cs:876)
MarsFPSKit.Weapons.Kit_ModernWeaponManager.AuthorativeInput (MarsFPSKit.Kit_PlayerBehaviour pb, MarsFPSKit.Kit_PlayerInput input, System.Single delta, System.Double revertTime) (at Assets/314 Arts/MarsFPSKit/Scripts/Player/Weapons/Kit_ModernWeaponManager.cs:608)
MarsFPSKit.Weapons.Kit_ModernWeaponManager.PredictionInput (MarsFPSKit.Kit_PlayerBehaviour pb, MarsFPSKit.Kit_PlayerInput input, System.Single delta) (at Assets/314 Arts/MarsFPSKit/Scripts/Player/Weapons/Kit_ModernWeaponManager.cs:614)
MarsFPSKit.Kit_PlayerBehaviour.PredictionInput (MarsFPSKit.Kit_PlayerInput input) (at Assets/314 Arts/MarsFPSKit/Scripts/Player/Kit_PlayerBehaviour.cs:724)
MarsFPSKit.Kit_PlayerBehaviour+<LocalPlayerRoutine>d__64.MoveNext () (at Assets/314 Arts/MarsFPSKit/Scripts/Player/Kit_PlayerBehaviour.cs:496)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <5eddeaad60a14d8ab4eb3a7453824232>:0)

using System.Linq;
using UnityEngine;
using Mirror;
using MarsFPSKit;
using MarsFPSKit.Weapons;

[RequireComponent(typeof(Collider))]
public class SimpleWeaponAutoPickupTrigger : NetworkBehaviour
{
    [Header("Weapon Settings")]
    public int weaponID = 0;

    [Header("Ammo Settings")]
    public int bulletsLeft = 30;
    public int bulletsLeftToReload = 60;
    public int[] attachments = new int[0];

    [Header("Respawn Settings")]
    [Tooltip("Rotating weapon prefab to respawn after pickup")]
    public GameObject respawnPrefab;

    [Tooltip("Seconds to wait before respawning the rotating weapon")]
    public float respawnTime = 10f;

    private Collider col;

    void Awake()
    {
        col = GetComponent<Collider>();
        if (!col.isTrigger)
        {
            col.isTrigger = true;
            Debug.LogWarning("Collider was not trigger, forced IsTrigger = true.");
        }

        if (!TryGetComponent<Rigidbody>(out var rb))
        {
            rb = gameObject.AddComponent<Rigidbody>();
            rb.isKinematic = true;
            Debug.Log("Added kinematic Rigidbody for trigger detection.");
        }
    }

    // This is a Mirror ServerCallback to ensure this only runs on server
    [ServerCallback]
    private void OnTriggerEnter(Collider other)
    {
        var player = other.GetComponentInParent<Kit_PlayerBehaviour>();
        if (player == null) return;

        TryPickup(player);
    }

    [Server]
    private void TryPickup(Kit_PlayerBehaviour player)
    {
        var wm = player.weaponManager as Kit_ModernWeaponManager;
        if (wm == null)
        {
            Debug.LogWarning("[Server] Player's weaponManager is not Kit_ModernWeaponManager.");
            return;
        }

        var runtimeData = player.weaponManagerNetworkData as Kit_ModernWeaponManagerNetworkData;
        if (runtimeData == null)
        {
            Debug.LogWarning("[Server] Player.weaponManagerNetworkData is not Kit_ModernWeaponManagerNetworkData.");
            return;
        }

        // Check if the player already has this weapon
        if (runtimeData.weaponsInUseDataObjects.Any(w => w != null && w.id == weaponID))
        {
            Debug.Log($"[Server] Player already has weapon ID {weaponID}, ignoring pickup.");
            return;
        }

        var weaponInfo = Kit_IngameMain.instance.gameInformation.allWeapons[weaponID];
        // Find a slot: either currentWeapon if can fit, else first allowed
        int slotToUse = weaponInfo.canFitIntoSlots.Contains(runtimeData.currentWeapon)
            ? runtimeData.currentWeapon
            : (weaponInfo.canFitIntoSlots.Length > 0 ? weaponInfo.canFitIntoSlots[0] : 0);

        if (Kit_IngameMain.instance.gameInformation.enableDropWeaponOnSceneSpawnedWeapons)
        {
            wm.DropWeapon(player, slotToUse);
        }

        // Use player’s API method to replace the weapon safely (handles syncing, visuals, etc.)
        player.ReplaceWeapon(slotToUse, weaponID, bulletsLeft, bulletsLeftToReload, attachments);

        Debug.Log($"[Server] Player {player.netId} picked up weapon ID {weaponID} in slot {slotToUse}");

        // Schedule respawn if manager exists
        if (WeaponPickupRespawner.Instance != null)
        {
            WeaponPickupRespawner.Instance.ScheduleRespawn(respawnPrefab, transform.position, transform.rotation, respawnTime);
        }
        else
        {
            Debug.LogWarning("WeaponPickupRespawner instance not found - cannot schedule respawn!");
        }

        // Destroy this pickup object on the server
        NetworkServer.Destroy(gameObject);
    }
}
using UnityEngine;

public class WeaponRotateAndSwivel : MonoBehaviour
{
    [Header("Rotation Settings")]
    public float rotationSpeed = 90f;  // degrees per second around Y-axis

    [Header("Swivel Settings")]
    public float swivelAngle = 10f;     // max tilt degrees
    public float swivelSpeed = 1.5f;    // cycles per second

    void Update()
    {
        // Calculate rotation angle around Y based on time
        float yRotation = (Time.time * rotationSpeed) % 360f;

        // Calculate swivel tilt angle (sine oscillation)
        float swivelOffset = Mathf.Sin(Time.time * swivelSpeed * Mathf.PI * 2) * swivelAngle;

        // Rotation around Y (horizontal spin)
        Quaternion yRot = Quaternion.Euler(0f, yRotation, 0f);

        // Swivel rotation (tilt forward/back) around X axis
        Quaternion swivelRot = Quaternion.Euler(swivelOffset, 0f, 0f);

        // Combine rotations:
        // First apply Y rotation (spin), then apply swivel tilt
        // So swivel is relative to the rotated forward pointing weapon
        transform.rotation = yRot * swivelRot;
    }
}
using System.Collections;
using UnityEngine;
using Mirror;

public class WeaponPickupRespawner : NetworkBehaviour
{
    public static WeaponPickupRespawner Instance;

    void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        Instance = this;
        // Persist if needed:
        // DontDestroyOnLoad(this.gameObject);
    }

    [Server]
    public void ScheduleRespawn(GameObject prefab, Vector3 pos, Quaternion rot, float delay)
    {
        StartCoroutine(RespawnAfterDelay(prefab, pos, rot, delay));
    }

    private IEnumerator RespawnAfterDelay(GameObject prefab, Vector3 pos, Quaternion rot, float delay)
    {
        yield return new WaitForSeconds(delay);

        if (prefab == null)
            yield break;

        GameObject go = Instantiate(prefab, pos, rot);
        NetworkServer.Spawn(go);
        Debug.Log($"[Server] Respawned pickup at {pos}");
    }
}
using MarsFPSKit.Weapons;
using Mirror;
using UnityEngine;

namespace MarsFPSKit
{
    [System.Serializable]
    public class WeaponToSpawn
    {
        /// <summary>
        /// The ID of the weapon to spawn
        /// </summary>
        public int weaponID = 0;
        /// <summary>
        /// The attachments that this weapon will spawn with
        /// </summary>
        public int[] attachmentsOfThisWeapon = new int[1];

        /// <summary>
        /// The amount of bullets this weapon will spawn with
        /// </summary>
        public int bulletsLeft = 30;
        /// <summary>
        /// The amount of bullets left to reload this weapon will spawn with
        /// </summary>
        public int bulletsLeftToReload = 60;
    }

    public enum WeaponSpawnType { Once, RespawnAfterTaken, RespawnAfterTime }

    /// <summary>
    /// This script will spawn weapons if attached to an object with a photonview
    /// </summary>
    public class Kit_WeaponSpawner : MonoBehaviour
    {
        /// <summary>
        /// Drop prefab
        /// </summary>
        public GameObject dropPrefab;

        /// <summary>
        /// List of weapons that could spawn here
        /// </summary>
        public WeaponToSpawn[] weaponsToSpawn = new WeaponToSpawn[0];

        /// <summary>
        /// Respawn type of this weapon.
        /// </summary>
        public WeaponSpawnType spawnType = WeaponSpawnType.Once;

        /// <summary>
        /// If <see cref="spawnType"/> is set  to <see cref="WeaponSpawnType.RespawnAfterTaken"/> or <see cref="WeaponSpawnType.RespawnAfterTime"/>, this is used
        /// </summary>
        public float respawnTime = 10f;

        /// <summary>
        /// At which time will this weapon be respawned next
        /// </summary>
        private double nextRespawnTime;

        /// <summary>
        /// Was this weapon spawned already?
        /// </summary>
        private bool wasWeaponSpawned;

        [HideInInspector]
        public Kit_DropBehaviour currentlySpawnedWeapon;

        void Start()
        {
            if (weaponsToSpawn.Length <= 0)
            {
                Debug.LogError("Weapon spawner (" + this + ") has no weapons assigned", this);
                return;
            }

            if (NetworkServer.active)
            {
                if (!currentlySpawnedWeapon && !wasWeaponSpawned)
                {
                    //Spawn Random weapon
                    SpawnWeapon(Random.Range(0, weaponsToSpawn.Length));

                    //If we only want to spawn once, set bool
                    if (spawnType == WeaponSpawnType.Once)
                    {
                        wasWeaponSpawned = true;
                    }
                    else if (spawnType == WeaponSpawnType.RespawnAfterTime)
                    {
                        nextRespawnTime = NetworkTime.time + respawnTime;
                    }
                    else if (spawnType == WeaponSpawnType.RespawnAfterTaken)
                    {
                        //Set time
                        nextRespawnTime = NetworkTime.time + respawnTime;
                    }
                }
            }
        }

        void Update()
        {
            if (NetworkServer.active)
            {
                if (weaponsToSpawn.Length > 0)
                {
                    if (spawnType == WeaponSpawnType.RespawnAfterTime)
                    {
                        if (NetworkTime.time > nextRespawnTime)
                        {
                            //Destroy old
                            if (currentlySpawnedWeapon)
                            {
                                NetworkServer.Destroy(currentlySpawnedWeapon.gameObject);
                            }

                            //Spawn new
                            SpawnWeapon(Random.Range(0, weaponsToSpawn.Length));

                            //Set time
                            nextRespawnTime = NetworkTime.time + respawnTime;
                        }
                    }
                    else if (spawnType == WeaponSpawnType.RespawnAfterTaken)
                    {
                        if (currentlySpawnedWeapon)
                        {
                            //Set time
                            nextRespawnTime = NetworkTime.time + respawnTime;
                        }
                        else
                        {
                            if (NetworkTime.time > nextRespawnTime)
                            {
                                //Spawn new
                                SpawnWeapon(Random.Range(0, weaponsToSpawn.Length));

                                //Set time
                                nextRespawnTime = NetworkTime.time + respawnTime;
                            }
                        }
                    }
                }
            }
        }

        void SpawnWeapon(int id)
        {
            if (NetworkServer.active)
            {
                if (Kit_IngameMain.instance.gameInformation.allWeapons[weaponsToSpawn[id].weaponID].dropPrefab)
                {
                    GameObject go = Instantiate(dropPrefab, transform.position, transform.rotation);
                    Kit_DropBehaviour dp = go.GetComponent<Kit_DropBehaviour>();
                    dp.isSceneOwned = true;
                    dp.weaponID = weaponsToSpawn[id].weaponID;
                    dp.bulletsLeft = weaponsToSpawn[id].bulletsLeft;
                    dp.bulletsLeftToReload = weaponsToSpawn[id].bulletsLeftToReload;

                    for (int i = 0; i < weaponsToSpawn[id].attachmentsOfThisWeapon.Length; i++)
                    {
                        dp.attachments.Add(weaponsToSpawn[id].attachmentsOfThisWeapon[i]);
                    }

                    NetworkServer.Spawn(go);

                    currentlySpawnedWeapon = dp;
                }
            }
        }

        /// <summary>
        /// Should be called by game mode scripts when game was started in the middle!
        /// </summary>
        public void GameModeBeginMiddle()
        {
            if (NetworkServer.active)
            {
                //Destroy if necessary
                if (currentlySpawnedWeapon)
                {
                    NetworkServer.Destroy(currentlySpawnedWeapon.gameObject);
                }

                //Spawn Random weapon
                SpawnWeapon(Random.Range(0, weaponsToSpawn.Length));

                //If we only want to spawn once, set bool
                if (spawnType == WeaponSpawnType.Once)
                {
                    wasWeaponSpawned = true;
                }
                else if (spawnType == WeaponSpawnType.RespawnAfterTime)
                {
                    nextRespawnTime = NetworkTime.time + respawnTime;
                }
                else if (spawnType == WeaponSpawnType.RespawnAfterTaken)
                {
                    //Set time
                    nextRespawnTime = NetworkTime.time + respawnTime;
                }
            }
        }
    }
}
using UnityEngine;
using UnityEditor;
using MarsFPSKit;
using MarsFPSKit.Weapons;
using System.Linq;
using System.Collections.Generic;

using UnityEngine.SceneManagement;
using UnityEditor.SceneManagement;

namespace MarsFPSKit
{

    [CustomEditor(typeof(Kit_WeaponSpawner))]
    public class Kit_WeaponSpawnerEditor : Editor
    {
        public static bool foldoutWeapons;

        public static bool foldoutSettings;

        public override void OnInspectorGUI()
        {
            Kit_WeaponSpawner spawner = (Kit_WeaponSpawner)target;

            if (!spawner.dropPrefab)
            {
                spawner.dropPrefab = EditorGUILayout.ObjectField("Drop Prefab", spawner.dropPrefab, typeof(GameObject), false) as GameObject;
            }
            else
            {
                if (!spawner.dropPrefab.GetComponent<Kit_DropBehaviour>())
                {
                    EditorGUILayout.HelpBox("Drop Prefab does not have Drop Behaviour on it", MessageType.Error);
                    spawner.dropPrefab = EditorGUILayout.ObjectField("Drop Prefab", spawner.dropPrefab, typeof(GameObject), false) as GameObject;
                }
            }

            Kit_IngameMain instance = FindObjectOfType<Kit_IngameMain>();

            if (instance)
            {
                if (spawner.weaponsToSpawn.Length <= 0)
                {
                    EditorGUILayout.HelpBox("Add a weapon! Otherwise this thing is useless.", MessageType.Warning);
                    if (GUILayout.Button("Add new weapon"))
                    {
                        List<WeaponToSpawn> wstList = new List<WeaponToSpawn>();
                        WeaponToSpawn wst = new WeaponToSpawn();
                        if (instance.gameInformation.allWeapons[wst.weaponID].GetType() == typeof(Kit_ModernWeaponScript))
                        {
                            wst.bulletsLeft = (instance.gameInformation.allWeapons[wst.weaponID] as Kit_ModernWeaponScript).bulletsPerMag;

                            wst.bulletsLeftToReload = (instance.gameInformation.allWeapons[wst.weaponID] as Kit_ModernWeaponScript).bulletsPerMag * 2;
                        }
                        wstList.Add(wst);
                        spawner.weaponsToSpawn = wstList.ToArray();
                    }
                }
                else
                {
                    foldoutWeapons = EditorGUILayout.Foldout(foldoutWeapons, "Weapons");

                    if (foldoutWeapons)
                    {
                        for (int i = 0; i < spawner.weaponsToSpawn.Length; i++)
                        {
                            //First, clamp ID
                            spawner.weaponsToSpawn[i].weaponID = Mathf.Clamp(spawner.weaponsToSpawn[i].weaponID, 0, instance.gameInformation.allWeapons.Length - 1);

                            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                            if (GUILayout.Button("Remove Weapon"))
                            {
                                //Convert to list
                                List<WeaponToSpawn> weps = spawner.weaponsToSpawn.ToList();
                                //Remove at
                                int id = i;
                                weps.RemoveAt(id);
                                //Go back
                                spawner.weaponsToSpawn = weps.ToArray();
                                return;
                            }

                            GUILayout.Label("Selected Weapon: " + instance.gameInformation.allWeapons[spawner.weaponsToSpawn[i].weaponID].weaponName.GetLocalizedString());
                            spawner.weaponsToSpawn[i].weaponID = EditorGUILayout.IntSlider("Weapon ID", spawner.weaponsToSpawn[i].weaponID, 0, instance.gameInformation.allWeapons.Length - 1);

                            if (instance.gameInformation.allWeapons[spawner.weaponsToSpawn[i].weaponID].GetType() == typeof(Kit_ModernWeaponScript))
                            {
                                Kit_ModernWeaponScript ws = instance.gameInformation.allWeapons[spawner.weaponsToSpawn[i].weaponID] as Kit_ModernWeaponScript;

                                if ((instance.gameInformation.allWeapons[spawner.weaponsToSpawn[i].weaponID] as Kit_ModernWeaponScript).reloadMode == ReloadMode.Chambered || (instance.gameInformation.allWeapons[spawner.weaponsToSpawn[i].weaponID] as Kit_ModernWeaponScript).reloadMode == ReloadMode.ProceduralChambered)
                                {
                                    spawner.weaponsToSpawn[i].bulletsLeft = EditorGUILayout.IntSlider("Bullets Left", spawner.weaponsToSpawn[i].bulletsLeft, 0, (instance.gameInformation.allWeapons[spawner.weaponsToSpawn[i].weaponID] as Kit_ModernWeaponScript).bulletsPerMag + 1);
                                }
                                else
                                {
                                    spawner.weaponsToSpawn[i].bulletsLeft = EditorGUILayout.IntSlider("Bullets Left", spawner.weaponsToSpawn[i].bulletsLeft, 0, (instance.gameInformation.allWeapons[spawner.weaponsToSpawn[i].weaponID] as Kit_ModernWeaponScript).bulletsPerMag);
                                }

                                spawner.weaponsToSpawn[i].bulletsLeftToReload = EditorGUILayout.IntField("Bullets Left to Reload", spawner.weaponsToSpawn[i]
                                    .bulletsLeftToReload);

                                //Check if attachments line up
                                if (ws.attachmentSlots.Length != spawner.weaponsToSpawn[i].attachmentsOfThisWeapon.Length)
                                {
                                    //Create new array
                                    spawner.weaponsToSpawn[i].attachmentsOfThisWeapon = new int[ws.attachmentSlots.Length];
                                }

                                //Loop through attachments
                                for (int o = 0; o < spawner.weaponsToSpawn[i].attachmentsOfThisWeapon.Length; o++)
                                {
                                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                                    //Display Attachment name
                                    GUILayout.Label("Attachment selected in slot [" + o + "]: " + ws.attachmentSlots[o].availableAttachments[spawner.weaponsToSpawn[i].attachmentsOfThisWeapon[o]].name);

                                    spawner.weaponsToSpawn[i].attachmentsOfThisWeapon[o] = EditorGUILayout.IntSlider("Attachment ID: ", spawner.weaponsToSpawn[i].attachmentsOfThisWeapon[o], 0, ws.attachmentSlots[o].availableAttachments.Length - 1);

                                    EditorGUILayout.EndVertical();
                                }
                            }
                            else
                            {
                                spawner.weaponsToSpawn[i].bulletsLeft = EditorGUILayout.IntField("Bullets Left", spawner.weaponsToSpawn[i]
                                    .bulletsLeft);
                                spawner.weaponsToSpawn[i].bulletsLeftToReload = EditorGUILayout.IntField("Bullets Left to Reload", spawner.weaponsToSpawn[i]
                                    .bulletsLeftToReload);
                            }
                            EditorGUILayout.EndVertical();
                        }

                        if (GUILayout.Button("Add new weapon"))
                        {
                            //Convert to list
                            List<WeaponToSpawn> weps = spawner.weaponsToSpawn.ToList();
                            WeaponToSpawn wst = new WeaponToSpawn();
                            if (instance.gameInformation.allWeapons[wst.weaponID].GetType() == typeof(Kit_ModernWeaponScript))
                            {
                                wst.bulletsLeft = (instance.gameInformation.allWeapons[wst.weaponID] as Kit_ModernWeaponScript).bulletsPerMag;

                                wst.bulletsLeftToReload = (instance.gameInformation.allWeapons[wst.weaponID] as Kit_ModernWeaponScript).bulletsPerMag * 2;
                            }
                            weps.Add(wst);
                            //Go back
                            spawner.weaponsToSpawn = weps.ToArray();
                        }
                    }
                }

                foldoutSettings = EditorGUILayout.Foldout(foldoutSettings, "Settings");
                if (foldoutSettings)
                {
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    spawner.spawnType = (WeaponSpawnType)EditorGUILayout.EnumPopup("Respawn type", spawner.spawnType);

                    if (spawner.spawnType == WeaponSpawnType.RespawnAfterTaken)
                    {
                        spawner.respawnTime = EditorGUILayout.FloatField("Respawn time after weapon was picked up (s): ", spawner.respawnTime);
                    }
                    else if (spawner.spawnType == WeaponSpawnType.RespawnAfterTime)
                    {
                        spawner.respawnTime = EditorGUILayout.FloatField("Respawn every (s): ", spawner.respawnTime);
                    }
                    EditorGUILayout.EndVertical();
                }

                if (GUI.changed)
                {
                    EditorUtility.SetDirty(spawner);
                    EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                }
            }
        }
    }
}
using Mirror;
using UnityEngine;
using System.Collections.Generic;  // For List<T>

namespace MarsFPSKit
{
    public enum AmmoSpawnType { Once, RespawnAfterTaken }

    /// <summary>
    /// Use this to place ammo packs in your levels
    /// </summary>
    public class Kit_AmmoSpawner : MonoBehaviour
    {
        /// <summary>
        /// The ammo prefab
        /// </summary>
        public GameObject ammoPrefab;

        /// <summary>
        /// Amount of clips this pickup will spawn
        /// </summary>
        public int amountOfClipsToPickup = 3;

        /// <summary>
        /// Respawn type of this ammo pickup
        /// </summary>
        public AmmoSpawnType spawnType;

        // SK START: Static list to track all ammo spawners in scene
        public static List<Kit_AmmoSpawner> allSpawners = new List<Kit_AmmoSpawner>();

        void OnEnable()
        {
            allSpawners.Add(this);
        }

        void OnDisable()
        {
            allSpawners.Remove(this);
        }

        /// <summary>
        /// Finds the nearest ammo spawner to the given position
        /// </summary>
        public static Kit_AmmoSpawner FindNearest(Vector3 position)
        {
            Kit_AmmoSpawner closest = null;
            float closestDist = float.MaxValue;

            foreach (var spawner in allSpawners)
            {
                float dist = (spawner.transform.position - position).sqrMagnitude;
                if (dist < closestDist)
                {
                    closestDist = dist;
                    closest = spawner;
                }
            }
            return closest;
        }
        // SK END

        /// <summary>
        /// If this is set to respawn, it will repsawn after this (in s)
        /// </summary>
        public float respawnTime = 10f;

        /// <summary>
        /// Was the ammo pack spawned already?
        /// </summary>
        private bool wasAmmoSpawned;

        /// <summary>
        /// When will it be repsawned the next time
        /// </summary>
        private float nextRespawnTime;

        [HideInInspector]
        public Kit_AmmoPickup currentlySpawnedAmmo;

        void Start()
        {
            if (NetworkServer.active)
            {
                if (!currentlySpawnedAmmo)
                {
                    if (spawnType == AmmoSpawnType.RespawnAfterTaken || spawnType == AmmoSpawnType.Once && !wasAmmoSpawned)
                    {
                        if (spawnType == AmmoSpawnType.RespawnAfterTaken)
                        {
                            //Set time
                            nextRespawnTime = Time.time + respawnTime;
                            //Spawn
                            SpawnAmmoPickup();
                        }
                        else if (spawnType == AmmoSpawnType.Once)
                        {
                            //Tell it to not spawn again !
                            wasAmmoSpawned = true;
                            //And spawn
                            SpawnAmmoPickup();
                        }
                    }
                }
            }
        }


        void Update()
        {
            if (spawnType == AmmoSpawnType.RespawnAfterTaken)
            {
                if (currentlySpawnedAmmo)
                {
                    //Set time
                    nextRespawnTime = Time.time + respawnTime;
                }
                else
                {
                    //None is spawned
                    //Check if we should repsawn?
                    if (Time.time > nextRespawnTime)
                    {
                        //Respawn
                        nextRespawnTime = Time.time + respawnTime;
                        SpawnAmmoPickup();
                    }
                }
            }
        }

        void SpawnAmmoPickup()
        {
            if (NetworkServer.active)
            {
                GameObject go = Instantiate(ammoPrefab, transform.position, transform.rotation);
                Kit_AmmoPickup pickup = go.GetComponent<Kit_AmmoPickup>();
                pickup.amountOfClipsToPickup = amountOfClipsToPickup;
                currentlySpawnedAmmo = pickup;
                NetworkServer.Spawn(go);
            }
        }

        /// <summary>
        /// Should be called by game mode scripts when game was started in the middle!
        /// </summary>
        public void GameModeBeginMiddle()
        {
            if (NetworkServer.active)
            {
                if (currentlySpawnedAmmo)
                {
                    NetworkServer.Destroy(currentlySpawnedAmmo.gameObject);

                    //Reset
                    currentlySpawnedAmmo = null;
                    wasAmmoSpawned = false;
                }

                //Just do the same again
                Start();
            }
        }
    }
}
using UnityEngine;
using UnityEditor;
using MarsFPSKit;
using System.Collections.Generic;

namespace MarsFPSKit
{
    [CustomEditor(typeof(Kit_AmmoSpawner))]
    public class Kit_AmmoSpawnerEditor : Editor
    {
        public static bool foldoutSettings;

        public override void OnInspectorGUI()
        {
            Kit_AmmoSpawner spawner = (Kit_AmmoSpawner)target;

            foldoutSettings = EditorGUILayout.Foldout(foldoutSettings, "Settings");

            if (!spawner.ammoPrefab || spawner.ammoPrefab && !spawner.ammoPrefab.GetComponent<Kit_AmmoPickup>())
            {
                if (spawner.ammoPrefab && !spawner.ammoPrefab.GetComponent<Kit_AmmoPickup>())
                {
                    EditorGUILayout.HelpBox("Object does not have necessary scripts!", MessageType.Error);
                }

                spawner.ammoPrefab = EditorGUILayout.ObjectField("Ammo Prefab", spawner.ammoPrefab, typeof(GameObject), false) as GameObject;
            }

            if (foldoutSettings)
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                spawner.spawnType = (AmmoSpawnType)EditorGUILayout.EnumPopup("Respawn type", spawner.spawnType);
                spawner.amountOfClipsToPickup = EditorGUILayout.IntField("Amount of clips", spawner.amountOfClipsToPickup);

                if (spawner.spawnType == AmmoSpawnType.RespawnAfterTaken)
                {
                    spawner.respawnTime = EditorGUILayout.FloatField("Respawn time after ammo was picked up (s): ", spawner.respawnTime);
                }
                EditorGUILayout.EndVertical();
            }
        }
    }
}

when the player picks up the weapon and is trying to shot a bot the error in the console appears and it freezes the gameplay, he cant move anymore.
Do not destroy the killing ability as this happend once before I asked you to fix this. The player should be able to kill bots and other players when he picks up the weapon.

In addition when the player picks up the weapon and shoots somehwere, and than when the weapon respawn he should be able to fill up his ammo and the weapon should disappear again for the specific amount of time. Use the provided scripts to make a 100% compatible system with MMFPSe without touching original mmfpse scripts
fix all scripts. Show 100% of the fixed script, ready to copy and paste