yield return WaitForSeconds not working

i have been trying to make a game in unity, and i have tried to add a power up function to it, i tired using the yield return WaitForSeconds function but it wont work, here is the section of code that doesn’t work

	}
}
IEnumerator Powerup(){
	if (count4 == 1) {
		speed = 20.5f;
		powerText.text = "SPEED ORB";
		yield return WaitForSeconds ("30");
		speed = 10.5f;
		count4 = 0;
		powerText.text = "No Power Up";
	
	}
}

}

when i go into the editor it gives the error of Expression denotes a type', where a variable’, value' or method group’ was expected

here is the full code just in case there is an error somewhere else;

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using UnityEngine.SceneManagement;

public class StoryPlayer : MonoBehaviour {

public float cubes;
public Text countText;
public Text winText;
public Text powerText;
public Text lifeText;
public Text crewText;
public Text timer;

private Rigidbody rb;
private int count;
private int count2;
private int count3;
private int count4;
private int count5;
private float speed;

void Start ()
{
	rb = GetComponent<Rigidbody>();
	count = 0;
	count2 = 0;
	count3 = 3;
	count4 = 0;
	count5 = 200;
	speed = 10.5f;
	SetCountText ();
	SetCrewText ();
	SetLifeText ();
	winText.text = "";
	powerText.text = "No Power Up";
}

void FixedUpdate ()
{
	float moveHorizontal = Input.GetAxis ("Horizontal");
	float moveVertical = Input.GetAxis ("Vertical");

	Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);

	rb.AddForce (movement * speed);
}

void OnTriggerEnter(Collider other)
{
	if (other.gameObject.CompareTag ("Pickup")) {
		other.gameObject.SetActive (false);
		count = count + 1;
		SetCountText ();
	}

	if (other.gameObject.CompareTag ( "Crew")){
		other.gameObject.SetActive (false);
		count2 = count2 + 1;
		SetCrewText ();
	}
	if (other.gameObject.CompareTag ( "Foe")){
		other.gameObject.SetActive (false);
		count3 = count3 - 1;
		SetLifeText ();
	}
	if (other.gameObject.CompareTag ("Speed")) {
		count4 = 1;
		StartCoroutine(Powerup ());
		while (count5 >= 0)
			other.gameObject.SetActive (false);
		if (count5 == 0)
			other.gameObject.SetActive (true);

	}
		
}

void SetCountText ()
{
	countText.text = "Cubes: " + count.ToString();
	if (count >= cubes && count2 >= 1)
	{
		winText.text = "YOU WIN!";
		Application.LoadLevel ("Chapter");

	}

}
void SetCrewText()
{
	crewText.text = "Crew: (" + count2.ToString () + "/1)";
}
void SetLifeText ()
{
	lifeText.text = "Life: (" + count3.ToString () + "/3)";
	if (count3 <= 0) 
	{
		winText.text = "YOU LOSE";
		Application.LoadLevel ("Chapter");

	}
}
IEnumerator Powerup(){
	if (count4 == 1) {
		speed = 20.5f;
		powerText.text = "SPEED ORB";
		yield return WaitForSeconds ("30");
		speed = 10.5f;
		count4 = 0;
		powerText.text = "No Power Up";
	
	}
}

}

if any one can help me fix this or even suggest an alternate method it would be greatly apreaciated

2 Answers

2

You can’t use a string in WaitForSeconds, only a number.

I did use a number, without "", and it gave the same problem

Unity 2017.1 simply begin to support inherit velocity in local simulation space. You don't need to do any additional thing, just update to 2017.1.

this website should help:
Unity - Scripting API: WaitForSeconds
also when you assign how many seconds you are waiting, you do not put “”
it should look like this:

	yield return WaitForSeconds(1);

WaitForSeconds is called with a new keyword as Eric5h5 said in his comment. So, this will throw an error.

That's the the thing, this doesn't seem to be the case or I am obviously doing something wrong, I set simulation space to local, tick inherit velocity, set it to -0,4 and start moving my particle system, no changes whatsoever... I have 2017.1.0b2 if that helps I've read through the additions to 2017 and only found that rate over distance is now supported in local space, nothing on inherit velocity :(