Statement is not a statemnt

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class moving : MonoBehaviour {
	public Rigidbody rb;
	public float movementspeed = 0.1f;
	public float brakingvelocity = 0.5f;
	// Use this for initialization
	void Start () {
	// Update is called once per frame
	void Update () {
		if (Input.GetKey ("w")) {
			transform.position += transform.forward * Time.deltaTime * movementspeed;


		if (Input.GetKey ("s")) {
			transform.position -= transform.forward * Time.deltaTime * brakingvelocity;
		while (Input.GetKey ("w"))
			movementspeed + 1f;

The while statement says that it is not a statement. Please help don’t hurry. :slight_smile:

This line:

movementspeed + 1f;

makes no sense. This whole expression will just evaluate to a float value but you don’t do anything with that value. So this is not a statement but just an expression which can not standalone.

You might wanted to do

movementspeed += 1f;

which is just a shorthand for

movementspeed = movementspeed + 1f;

However your while loop would make your game and the Unity editor to freeze / hang so it has to be force closed because once you press down the “w” key you can never exit the while loop. The input only changes between frames. Since you never complete the current frame once GetKey(“w”) returns true it will stay true and you’re stuck forever inside that while loop.

It’s hard to tell what you actually wanted to do since your question is lacking a proper description.