Error while in class, struct, or interface

No matter how I write this I seem to constantly be getting the error

using UnityEngine;

public class CurrentTime : MonoBehaviour {

	public float
	TimeH = 0,
	TimeM = 0,
	TimeS = 0;

	public bool FastForward, Rewind, ActiveTime;

	void Update (){

			if (TimeS > 59) {
				TimeM++;
				TimeS -= 60;
			}
			if (TimeM > 59) {
				TimeH++;
				TimeM -= 60;
			}
			if (TimeH > 23) {
				TimeH -= 24;
			}
	
			if (TimeS < -1) {
				TimeM--;
				TimeS += 60;
				}
			if (TimeM < -1) {
				TimeH--;
				TimeM += 60;
				}
			if (TimeH < -1) {
				TimeH += 24;
				}

	}
	while (ActiveTime){
	if (FastForward) {
		{TimeS += 10;}
	}
	else if (Rewind) {
		{TimeS -= 10;}
		}
	else{
		{TimeS ++;}
		}
	}
}

How do I get the while to work? I tried putting it before the update void

I originally had it in the “void Update” but it was doing TimeS++ 10 times a second, I was thinking of having Void Update in while but will I have to have that after every if?

I plan to use this script to control time in my game

The Update() function runs once per frame, not once per second. You’ll probably want to increase TimeS by Time.deltaTime, which is the time it took for the current frame to render.
You might also want to change:

if (TimeS > 59) to if (TimeS > 60)

if (TimeM > 59) to if (TimeM > 60) and

if (TimeH > 23) to if (TimeH > 24)

Since Time.deltaTime tends to have values lower than 1, >59 for instance would reset your minutes to 0 on a value such as 59.02, making you have a 59 minute hour.

The while-loop needs to be used inside a method or a constructor just like an if-clause or a for-loop.

If I understand right, you’re trying to increment time at normal pace if ActiveTime (Play mode) is true, and if FastForward or Rewind are true, increment/decrement at 10x speed ?

Probably something like this in your Update method would accomplish what you want (Prof. Snake’s fixes included):

void Update (){

		if (ActiveTime)
		{
			float secondsPassed = Time.deltaTime;

			if (Rewind)
			{
				secondsPassed *= -10;
				TimeS += secondsPassed;

				// handle negative conditions only here where time is going backwards
				if (TimeS < 0) {
					TimeM--;
					TimeS += 60;
				}
				if (TimeM < 0) {
					TimeH--;
					TimeM += 60;
				}
				if (TimeH < 0) {
					TimeH += 24;
				}
			}
			else
			{
				// time running forward
				if (FastForward)
				{
					secondsPassed *= 10;
				}
				TimeS += secondsPassed;

				if (TimeS > 60) {
					TimeM++;
					TimeS -= 60;
				}
				if (TimeM > 60) {
					TimeH++;
					TimeM -= 60;
				}
				if (TimeH > 24) {
					TimeH -= 24;
				}
			}
		}
	}

*edit for separate handling of fwd/rew