Scripts disappearing from second player in unity multiplayer game

I’m making a multiplayer game in Unity using Netcode for GameObjects. After implementing a camera for each player that follows them, I realised that, when the client joins, the script that allows the player to control its character simply disappears. Therefore, the player can’t move. The Camera Controller script does the same thing. I also get no errors.
There’s also a Player Network script that I usually keep disabled, because I don’t need it right now. However, when I do try to enable it, when the client spawns, the scripts are still not there, but I also get these two errors:

[Netcode] NetworkBehaviour index 3 was out of bounds for Player(Clone). NetworkBehaviours must be the same, and in the same order, between server and client.

and

[Netcode] Network variable delta message received for a non-existent behaviour. NetworkObjectId: 2, NetworkBehaviourIndex: 3

There’s some more text that follows these errors, which I believe pinpoints where the errors came from, but they’re part of some scripts or functions that are included in the Netcode package I think? Let me know if you need the full errors.
It’s probably unrelated to my first issue, but it probably shows that the PlayerNetwork script is also broken. I’m gonna be honest, I followed a tutorial when making it and I don’t actually understand much from it.

Here are the scripts:
Player:

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

public class Player : NetworkBehaviour
{
    private Rigidbody playerRb;
    public GameObject camHolderPrfb;
    public GameObject camHolder;
    public float speed;
    public float jumpForce;
    public float gravityMod;
    private bool onGround = true;

    void Start()
    {
        camHolder = Instantiate(camHolderPrfb, transform.position, Quaternion.identity);
        playerRb = GetComponent<Rigidbody>();
        Physics.gravity *= gravityMod;
    }

    void Update()
    {
        //Makes sure player can only control its character
        if (!IsOwner) {enabled = false;} 
        //Calculates player movement
        float forwInput = Input.GetAxis("Vertical");
        float horzInput = Input.GetAxis("Horizontal");
        Vector3 direction = camHolder.transform.forward * forwInput + camHolder.transform.right * horzInput;
        //Applies movement to player
        if (direction.magnitude > 1) {direction.Normalize();}
        playerRb.AddForce(direction * speed);
        
        //Allows player to jump
        if(Input.GetKeyDown(KeyCode.Space) && onGround) {
            onGround = false;
            playerRb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
        }
    }
    
    //Ensures player can only jump if it's touching the ground
    void OnCollisionEnter(Collision collision) 
    {
        if (collision.gameObject.CompareTag("Ground")) {
            onGround = true;
        }
    }
}

Camera Controller:

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

public class CamController : NetworkBehaviour
{

    public float rotationSpeed;
    public float lerpSpeed;
    public GameObject camHolder;
    private Camera playerCamComp;
    private GameObject playerCam;
    public Player PlayerScr;

    void Start() 
    {
        camHolder = PlayerScr.camHolder;
        playerCamComp = camHolder.GetComponentInChildren<Camera>();
        playerCam = playerCamComp.gameObject;
    }

    void FixedUpdate()
    {
        //Camera is rotatable with left and right keys
        float camInput = Input.GetAxis("MoveCam");
        camHolder.transform.Rotate(Vector3.up, camInput * Time.deltaTime * rotationSpeed);
        //Camera moves and looks at the player
        camHolder.transform.position = Vector3.Lerp(camHolder.transform.position, transform.position, lerpSpeed * Time.deltaTime);
        playerCam.transform.LookAt(this.transform);
    }
}

Player Network:

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


[System.Serializable]
public struct PlayerNetworkState : INetworkSerializable
{
    public Vector3 Position;
    public Vector3 Rotation;

    public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
    {
        serializer.SerializeValue(ref Position);
        serializer.SerializeValue(ref Rotation);
    }
}


public class PlayerNetwork : NetworkBehaviour
{
    [SerializeField] private bool usingServerAuth;
    private NetworkVariable<PlayerNetworkState> playerState;
    private Rigidbody playerRb;

    private void Awake()
    {
        playerRb = GetComponent<Rigidbody>();
        var permission = usingServerAuth ? NetworkVariableWritePermission.Server : NetworkVariableWritePermission.Owner;
        playerState = new NetworkVariable<PlayerNetworkState>(new PlayerNetworkState {Position = Vector3.zero, Rotation = Vector3.zero}, NetworkVariableReadPermission.Everyone, permission);
    }

    public override void OnNetworkSpawn()
    {
        if (!IsOwner) {
            Destroy(transform.GetComponent<Player>());
            Destroy(transform.GetComponent<CamController>());
        }
    } 

    private void Update()
    {
        if (IsOwner) TransmitState();
        else ConsumeState();
    }

    #region Transmit State

    private void TransmitState()
    {
        var state = new PlayerNetworkState
        {
            Position = playerRb.position,
            Rotation = transform.rotation.eulerAngles
        };

        if (IsServer || !usingServerAuth)
        {
            playerState.Value = state;
        }
        else
        {
            TransmitStateServerRpc(state);
        }
    }

    [ServerRpc(RequireOwnership = false)]
    private void TransmitStateServerRpc(PlayerNetworkState state)
    {
        playerState.Value = state;
    }

    #endregion

    #region Consume State

    private void ConsumeState()
    {
        transform.position = playerState.Value.Position;
        transform.rotation = Quaternion.Euler(playerState.Value.Rotation);
    }

    #endregion
}

The internet simply didn’t give me anything related, so the solution might not be very straightforward. Please let me know if you need any additional information, like the Network Manager configuration or stuff like that. There’s also a script that only makes buttons to join the game as a host or a client, but zi don’t think it’s relevant.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật