Light toggle only while player is moving?

im trying to get a light to temporarily toggle while the player is in motion. it should turn off once the player has stopped moving. I tried to do this a simple way but I get an error saying that

“Only assignment, call, increment, and decrements, and new object expressions can be used as a statement”

Here is my thoughts.

rigbod = GetComponent<Rigidbody>();
togLight = GetComponent<Light>();

if(rigbod.velocity.magnitude > 0){
togLight.enabled;
}

advice?

You cant use enabled without assigning it anything, the compiler may not know if “enabled” should be true, or false (since enabled is a bool)

Youd want to change that line to togLight.enabled = true;

So your entire bit of code, may look something like:

if(rigbod.velocity.magnitude > 0){
    togLight.enabled = true;
}
else {
    togLight.enabled = false;
}