Show Float and edit from another script.

Hello community!
I have a question, and I would like to know how to solve it.

I have two scripts: A and B
A contains a value.
B shows the value of A.
I would like to modify the value shown by B, but it cannot be done, since it only shows the value of A.

ex:
public class A : monoB{
public float val = 0;
}

public class B : monoB{
public float value;
public A a;
void Update(){
value = a.val; // aqui solo muestro el valor de A, pero no puedo modificarlo.
}
}

How could it be shown and at the same time edit the value from script B?

thank you!

try this on script A:

public float _number = 0; // default value = 0

public float number

{
get{return _number;} // to return the value of _number
set{ _number = value; } // to set the value of _number
}

then change the script A variable of “number” from script B

You need to reference script instance, in script A , add: public classB class_b; drag the script in the inspector. and then in Start() of script A for example you can say : class_b.val = 5;