So i want to use a public float variable from one script in another one

so i have 2 scripts one which is my PlayerController script and the second one whch is Player and in Player i have a calculation:

public void Slow (float pct)
{
speed = maxSpeed * (1f - pct);
}

for the enemy ai turrent which slows the player but i need to call the “maxSpeed” variable from my PlayerController script in order for it to work and i dont know how to do that.

If you have only one player, you could make this variable static, like :

public class Player : Monobehaviour
{
    public static float maxSpeed ;
}

public class EnemyAI : Monobehaviour
{
    void Update ()
    {
        float maxSpeed = Player.maxSpeed;
    }
}