Help with simple scripting?

Hello! I want my gameobject (cube) to change it’s color in a loop. I would also like to have my loop stop after about 30 seconds. I tried to make a script for it but it didn’t work. If my script is’nt even close to what I’m trying to do, could someone make me one or tell me what’s wrong in it.

yield WaitForSeconds (16.8);
{
	for {
		renderer.material.color = Color(1, 0, 0, 1); 
		yield WaitForSeconds (0.183);
		{
			renderer.material.color = Color(0, 1, 0, 1);
			yield WaitForSeconds (0.183);
				{
					renderer.material.color = Color(1, 0.92, 0.016, 1);
					yield WaitForSeconds (0.183);
						{
							renderer.material.color = Color(0, 0, 1, 1);
							yield WaitForSeconds (0.183);
						}
				}
		}
	}
}

Your code syntax looks very odd. I would structure your code like this:

function FunctionName() {
	yield WaitForSeconds (16.8);

	renderer.material.color = Color(1, 0, 0, 1); 
	yield WaitForSeconds (0.183);

    renderer.material.color = Color(0, 1, 0, 1);
    yield WaitForSeconds (0.183);

    renderer.material.color = Color(1, 0.92, 0.016, 1);
    yield WaitForSeconds (0.183);

    renderer.material.color = Color(0, 0, 1, 1);
    yield WaitForSeconds (0.183);
}

However, the first WaitForSeconds (16.8) waits for 16.8 seconds before changing color the first time, so that’s probably not what you’re after. After that you then change colors with 0.183 seconds between each switch, which is extremely fast, try increasing those values.