problem with prefab's script

I know for sure that this question has been answered before but because in each answer the solution presented was adjusted to someone’s classes, variables, etc it was difficult for me , who just begun to work in unity, to understand it.

My problem through a very general example :
I create a cube in the Hierarchy using the create button. Then I drag the cube from the hierarchy to the project tab (so im creating its prefab i guess). Then i add the following js script, named Cube_script, to both “hierarchy cube” and “prefab cube”:

#pragma strict

public var variable = 10000000;

function Start () {    
}
function Update () {

variable = variable - 1;
}

Then i hit play and i observe from the inspector that that the variable from the “hierarchy cube” is decreasing but the variable from the “prefab cube” is staying the same. All i want to do is to force the variable of the “prefab cube” to “follow” the variable of the “hierarchy cube”.

It sounds like you have the “hierarchy cube” in the hierarchy while the “prefab cube” is not. The prefab is not being updated because it is not meant to – it is simply a reference that you can make instances of in the scene. Your “hierarchy cube” is one such instance. If you want a variable in the prefab to be the same across all instances, you can try making that variable static, like this:

 static var variable = 10000000;
 
 function Start () {    
 }
 function Update () {
 
 variable -= 1;
 }