Random.value is giving error and not functioning when assigned to a variable

I’m quiet a noob here so this question might seem trivial.
But I am attempting to create a situation where the chance of a character dying is 50% and that of the opponent dying also 50%. The Random.value function which chooses a number randomly from 0-1 should have done the trick, but I get this error message:

get_value can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don’t use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.

Below is a portion of the script. Thanks:)

var hey= Random.value;
if(hey>0.5){
//script for death of player belongs here
}else{
//script for death of opponent belongs here

All code must be inside a function. Do what the error says and put that in Awake or Start.