RPG Stat Based Turn System

Main Question
How do I make one script reference and compare the values of variables in another script on multiple game objects?

Info
I’m working on an RPG similar to Final Fantasy Tactics or Final Fantasy Tactics A2. I have the main cursor movement and maps done, but I still need to fix the unit system. The problem is I need a turn system that compares the speed values of all units, and makes the highest one go first, and I have no clue how to do this. If anyone could help me, it would be greatly appreciated.

What I Have:

Stats:

var maxHP = 10;
var maxMP = 10;

var str = 10;
var end = 10;
var prc = 10;
var wis = 10;
var res = 10;
var spd = 10;
var acc = 10;

var move = 5;
var jump = 2;

var curHP : int;
var curMP : int;

var redBox : GUIStyle;
var blueBox : GUIStyle;
var word : GUIStyle;

private var nextMove : float = 0.0;

function Start ()
{
  curHP = maxHP;
  curMP = maxMP;
}
function OnGUI ()
{
  var hit : RaycastHit;
  var layerMask = 1 << 9;
  if (Physics.Raycast ((Vector3(0,-1,0) + transform.position), Vector3.one, hit, 1, layerMask))
  {
    GUI.Box (Rect (10,Screen.height-40,(Screen.width * curHP)/(2 * maxHP),20),"",redBox);
    GUI.Box (Rect (10,Screen.height-70,(Screen.width * curMP)/(2 * maxMP),20),"",blueBox);
    GUI.Box (Rect (10,Screen.height-40,(Screen.width/2),20), curHP+ "/" +maxHP, word);
    GUI.Box (Rect (10,Screen.height-70,(Screen.width/2),20), curMP+ "/" +maxMP, word);
    GUI.Box (Rect (10,Screen.height-85,(Screen.width/2),80), "");
  }

  if (curHP < 0)
  curHP = 0;
  if (curMP < 0)
  curMP = 0;

  if (curHP > 0)
  curHP = maxHP;
  if (curMP > 0)
  curMP = maxMP;
}

Turn System(This is my problem):

 //place >> turn start > units > turn end
    //  turn start - start of turn
    //  units - use units for movement, attack, and defence
    //  turn end - resets speed value and returns to start
    function Start ()
    {
      BroadcastMessage("Place");
    }
    
    function Place ()
    {
      BroadcastMessage("Turn");
    }
    
    function Turn ()
    {
      var tem : Stats;
      tem = gameObject.GetComponentInChildren(Stats);
    }
    
    function Update ()
    {
    
    }

I figured out how by myself…

This is potentially a very large and complicated system you’re describing. You might try starting with something smaller as a learning project.

Either way, my advice is about the same: consider each piece of your system. What does it do? What information does it need to do that? What systems can you build to provide data, functionality, and support?

It’s useful to consider both frontend and backend: how will your player interact with the system, and how will those interactions affect the internal state of your game? Maybe you need a data structure to represent the player’s current equipment. If so, what values should you store in it?

For example, let’s say you want the player to equip a weapon. Perhaps you need a menu for that. Once the weapon is equipped, the player’s attacks should be more effective (maybe they hit more often, or deal more damage). How can your game’s programming represent that? What other values should affect the player’s attacks?

Once you’ve defined the pieces of your system, building it should be more straightforward. Break your big problem into smaller ones that are easier to solve.

If you want a more specific answer, you’ll need to ask a more specific question.