help coding for slider ui for player attributes

Im getting a nullreference for this code below which suppose to reference from the playercontroller, can someone check it this out tnks.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class DiseaseProgression : MonoBehaviour
{
    [Header("Disease Progression Bar")]
    public Slider slider;
    float timeToWait = 1f;
    float fillQuantity = 2f;
  

    [Header("Reference")]
    private PlayerController1 m_Player1;
    private PlayerController2 m_Player2;

    // Start is called before the first frame update
    void Start()
    {
        StartCoroutine(FillSlider());

        m_Player1 = GetComponent<PlayerController1>();

    }

    public IEnumerator FillSlider()
    {
        yield return new WaitForSeconds(timeToWait);
        slider.value += fillQuantity;
        StartCoroutine(FillSlider());
    }

    public void OnValueChanged(int speedReduction40 = 15)
    {
       
        if (slider.value >= 40)
        {
            m_Player1.moveSpeed = (speedReduction40 / 100) * m_Player1.moveSpeed;        
        }
        else
        {
            FillSlider();
        }
      
       
    }

}
public class PlayerController1 : MonoBehaviour
{

    [Header("References")]
    private Rigidbody2D rb; //Store a reference to the Rigidbody2D component required to use 2D physics
    public Animator myAnim;  //Store a reference to the Animator component. Needs to be accessible for AttackController
    private LevelManager theLevelManager;
    private EnemyAIController theEnemy; //Make a reference to an object of EnemyController *To be unchecked*
    AttackController1 m_Attack;
    SpriteRenderer m_sr;
    public PlayerController1 m_Player1;
    private PlayerController2 m_Player2;
  

    [Header("Respawn Position")]
    //Store a respawn position the player will go to whenever she dies.
    public Vector3 respawnPosition;

    [Header("Movement")]
    //Control speed of player that is moving
    public float moveSpeed;
    public bool canMove = true;

    [Header("Jump")]
    //Jump Variables
    public float jumpSpeed; //Control the speed when player jumps
    public float jumpForce; //Control the strength and added force of jump
    private bool doubleJump; //Control the jump when he player jump double times or click spacebar double times

    private float jumpPressedRemember;
    public float jumpPressedRememberTime;

    private float GroundedRemember;
    public float GroundedRememberTime;

    //Enable or Disables double jump feature
    public bool canDoubleJump;

    [Header("Ground Variables")]
    //Ground detection variables
    public Transform groundCheck; //A point is space to check where the ground is
    public float groundCheckRadius;
    public LayerMask realGround;
    public bool isGrounded;

    [Header("Knockback")]
    //Knockback Variables
    public float knockbackForce; //Knockback strength
    public float knockbackDuration; //Duration in seconds of every knockback
    private float currentKnockbackDuration; // Remaining duration of existing knockback

    [Header("Better Jump")]
    //Jump Modifications
    public float highJumpMultiplier = 2.5f;
    public float lowJumpMultiplier = 2f;

    [Header("Melee Attack System")]
    //Attack System
    public float PlayerDamage = 100;

    private float timeBetweenAttacks;
    [HideInInspector] public float startTimeBetweenAttacks;
    public float defaultTimeBetweenAttacks;
    public float TimeBetweenAttacksMultiplier;

    public Transform AttackPos;
    public LayerMask WhoIsEnemy;

    [Header("Invunerable effect")]
    public float blinkTime;

    [HideInInspector] public float CurrentPlayerDamage;

    [Header("Key System")]
    private List<Key.KeyType> keyList;

    //Tag System
    [HideInInspector] public bool activePlayer;

 


    // Start is called before the first frame update
    void Start()
    {
        //Get and store a reference to the Rigidbody2D component so that we can access it.
        rb = GetComponent<Rigidbody2D>();
        //Access animator component.
        myAnim = GetComponent<Animator>();
        respawnPosition = transform.position; //When game starts, respawn position equals to the current players position.
        m_sr = GetComponent<SpriteRenderer>();
        theLevelManager = FindObjectOfType<LevelManager>();
        m_Attack = GetComponentInChildren<AttackController1>();
        m_Player1 = GetComponent<PlayerController1>();
        m_Player2 = GetComponent<PlayerController2>();
   

        startTimeBetweenAttacks = defaultTimeBetweenAttacks;
        CurrentPlayerDamage = PlayerDamage;
        Debug.Log(CurrentPlayerDamage);

    }

    // Update is called once per frame
    void Update()
    {
        if (!canMove)
        {

            //Mathf.Abs function returns the absolute value of velocity rigidbody along 'x' axis.
            myAnim.SetFloat("Speed", Mathf.Abs(rb.velocity.x));

            //SetBool is used to trigger transitions between Animator states.
            myAnim.SetBool("Ground", isGrounded);
            return;
        }

        if (currentKnockbackDuration <= 0) // If we are currently being knocked back, this will disable all player controls
        {
            //Player Blinking
            if (blinkTime > 0)
            {
                m_sr.color = new Color32(200, 200, 200, 230);
                blinkTime -= Time.deltaTime;
            }
            else
            {
                m_sr.color = new Color32(255, 255, 255, 255);
            }

            //Attack Animation, set exit time on animator that links to Player_Attack so it does not jerk.

            if (timeBetweenAttacks <= 0)
            {
                if (Input.GetKeyDown(KeyCode.L))
                {

                    m_Attack.attack();
                    Debug.Log("Pressed the L Key.");
                    //Attack Availability
                    timeBetweenAttacks = startTimeBetweenAttacks;

                    //theLevelManager.swordSound.Play();
                }
            }
            else
            {
                timeBetweenAttacks -= Time.deltaTime;
            }

         

            float h = Input.GetAxisRaw("Horizontal"); //Movement Variable
           


            //Movement Controls
            rb.velocity = new Vector2(moveSpeed * h, rb.velocity.y);         



            if (h > 0) //when its more than 0 it will face right
            {             
                    transform.localScale = new Vector3(1, 1, 1);            
            }
            else if (h < 0) //when its less than 0 it will face left
            {             
                    transform.localScale = new Vector3(-1, 1, 1);
            }

            rb.velocity = new Vector2(moveSpeed * h, rb.velocity.y);

            jumpPressedRemember -= Time.deltaTime;
            GroundedRemember -= Time.deltaTime;

            if (isGrounded)
            {
                GroundedRemember = GroundedRememberTime;
            }

            if (Input.GetButtonDown("Jump"))
            {
                jumpPressedRemember = jumpPressedRememberTime;
            }

            //Jump Controls
            if (jumpPressedRemember > 0 && GroundedRemember > 0)
            {
                jumpPressedRemember = 0;
                GroundedRemember = 0;
                //For Jumping
                rb.velocity = new Vector2(rb.velocity.x, jumpSpeed);

                rb.AddForce(new Vector2(0, jumpForce));

                //Jump if player is grounded from IsGrounded
                doubleJump = true;

                //Play dust effect when jumping
                //CreateDust();

                rb.velocity = Vector2.up * jumpForce;
            }
            else if (doubleJump == true && Input.GetButtonDown("Jump"))
            {
                if (!canDoubleJump) return;
                //Condition to prevent infinite jumping

                rb.AddForce(new Vector2(5, jumpForce));

                //Does not make player jump again when player is in the air from using player's already double jump and that the jump button is already pressed and used
                doubleJump = false;

                //Play dust effect when jumping
                //CreateDust();

                rb.velocity = Vector2.up * jumpForce;
            }

            //To create circle and checking collision.
            isGrounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, realGround);

            //Mathf.Abs function returns the absolute value of velocity rigidbody along 'x' axis.
            myAnim.SetFloat("Speed", Mathf.Abs(rb.velocity.x));

            //SetBool is used to trigger transitions between Animator states.
            myAnim.SetBool("Ground", isGrounded);

        }
        else
        {
            //Handle the situation we are currently being knocked back.
            currentKnockbackDuration -= Time.deltaTime;

            //Force the knockback of the player
            if (transform.localScale.x > 0)
            {
                rb.velocity = new Vector3(-knockbackForce, knockbackForce * .5f, 0.0f);
            }
            else
            {
                rb.velocity = new Vector3(knockbackForce, knockbackForce * .5f, 0.0f);
            }
        }

      

    }//End Of Void Update

    public void Knockback()
    {
        currentKnockbackDuration = knockbackDuration;
    }

    void FixedUpdate()
    {
        //Jump Modifications
        if (rb.velocity.y < 0)
        {
            rb.velocity += Vector2.up * Physics2D.gravity.y * (highJumpMultiplier - 1) * Time.deltaTime;
        }
        else if (rb.velocity.y > 0 && !Input.GetButton("Jump"))
        {
            rb.velocity += Vector2.up * Physics2D.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime;
        }
    }//End Of FixedUpdate.

    //Variable to trigger player respawn & key colliding.
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "KillPlane")
        {
            theLevelManager.Respawn();
        }

        Key key = other.GetComponent<Key>();

        if (key != null)
        {
            AddKey(key.GetKeyType());
            Destroy(key.gameObject);
        }

        KeyDoor keyDoor = other.GetComponent<KeyDoor>();
        if(keyDoor != null)
        {
            if(ContainsKey(keyDoor.GetKeyType()))
            {
                //Currently holding Key to open this door
                RemoveKey(keyDoor.GetKeyType());
                keyDoor.OpenDoor();
            }
        }

    }

    //To play dust effect when jumping.
    void CreateDust()
    {
        //dust.Play();
    }

    public bool isFalling()
    {
        if (rb.velocity.y < 0) return true;
        return false;
    }

    public void takeHit(int damage)
    {
       
        theLevelManager.HurtPlayer(damage, true);
    }

    //CollisionEnter for player entering MovingPlatform.
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "MovingPlatform")
        {
            gameObject.transform.parent = collision.transform;        
        }


    }

    //CollisionExit for player exiting MovingPlatform.
    void OnCollisionExit2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "MovingPlatform")
        {          
            gameObject.transform.parent = null;               
        }

    }

    private void Awake()
    {
        keyList = new List<Key.KeyType>();
    }//End Of Awake.

    public void AddKey(Key.KeyType keyType)
    {
        Debug.Log("Added Key: " + keyType);
        keyList.Add(keyType);
    }

    public void RemoveKey(Key.KeyType keyType)
    {
        keyList.Remove(keyType);
    }

    public bool ContainsKey(Key.KeyType keyType)
    {
        return keyList.Contains(keyType);
    }

  
}

Under the Onvaluechanged which supposed to affect the movespeed tnks.

I’m developing a new response to this most-common question:

http://plbm.com/?p=221

Feedback and comments to that post are always welcome.

actually its more of the slider value not affecting the player stats, any hints? like the parameters to code a bar to affect player movespeed/ attackspeed etc. tnks

  1. fix the nullref; if you don’t fix the nullref, all the hints in the world won’t help you. IF you fixed the nullref, then:

  2. start inserting Debug.Log() statements to see what values are coming from where, and to determine if you’re even calling the code you think you are… this is Debugging 101.