Jumping Problem

I am making a simple game and i need my player to jump. They way i want to do it i get the error: Operator ‘&&’ cannot be applied to operands of type ‘bool’ and ‘float’. Here is my script:
public class Jump : MonoBehaviour
{
public Rigidbody rb;
public float UpForce = 2000f;
public float jumpCount;

void FixedUpdate()
{
    if (Input.GetKey("w") && jumpCount = 0)
    {
        rb.AddForce(0, UpForce * Time.deltaTime, 0, ForceMode.Impulse);
        jumpCount = 1f;
    }

}

void OnCollisionEnter(Collision collisionInfo)
{
    if (collisionInfo.collider.tag == "Floor")
    {
        jumpCount = 0f;
    }
}

The problem is a really simple one:

You used = instead of ==.

Remember that = is assignment, == is comparison. That is, if you have two variables, A and B, both of type float, then the expression

(A==B)

is actually a bool, which you can use with the && operator or put into an if statement. But the expression

(A=B)

is one that will set A to the value of B, and also, because of how C# works, return the value of B (which is also now A) as a float.

In your code, the problem line is:

 if (Input.GetKey("w") && jumpCount = 0){
...
}

Now, if expects a bool, and, unlike C++ or other languages, will not accept any other type. Now, you are feeding it the expression

 (Input.GetKey("w") && jumpCount = 0)

which uses the && operator. The && operator returns a bool (just what you want for an if statement), and expects two bools, one on the left and one on the right. The left side of your AND operator is:

Input.GetKey("w")

which is a method that returns a bool. Perfect. Now the right side of your AND operator is all that’s left. The expression:

(jumpCount = 0)

This expression says “Set jumpCount to 0, then return the value of jumpCount afterwards.”. Since jumpCount is a float, then the whole expression returns a float. Since this is C#, which has fairly strict type enforcement, there’s no way that a float can just be treated as a bool. So there lies your problem. You are trying to use && with a bool and a float, when it expects 2 bools.

What you probably meant to do is Check whether jumpCount was 0, returning TRUE if so and FALSE otherwise. That expression looks like this:

(jumpCount == 0) //Notice the == instead of =

Now, == is a comparison which returns a bool. So now you have a correct bool && bool, instead of the incorrect bool && float.