Assets\PlayerStuff.cs(5,42): error CS1031: Type expected (i don't know what to do!)

so, i was coding my super smash bros type game when i got this error after making player movement script

here’s the script

start script:

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

public class PlayerStuff : MonoBehaviour,

{
void Update()
{
if ( Input.GetKey(“d”) )
{
Rigidbody.AddForce(100 * Time.deltaTime, 0, 0);
}

if ( Input.GetKey(“a”) )
{
Rigidbody.AddForce(-100 * Time.deltaTime, 0, 0);
}

}
}

end script

please help! i need to finish this game for an assignment :confused:

Remove the “,” after MonoBehaviour (Line 5) - that should be it. :slight_smile:

Next time you can try to debug it by yourself:
“A**ssets\PlayerStuff.cs(5,42)” means that there is a problem in the fifth line at character 42.
“Type expected” occurs because the “,” after MonoBehaviour indicates that you want to implement an internface to your script (https://learn.unity.com/tutorial/interfaces)

First off, i did debug it myself for about 6 hours, second off i need the “,” there or else i get this error: Assets\PlayerStuff.cs(13,3): error CS0120: An object reference is required for the non-static field, method, or property ‘Rigidbody.AddForce(float, float, float)’

and this error: Assets\PlayerStuff.cs(13,3): error CS0120: An object reference is required for the non-static field, method, or property ‘Rigidbody.AddForce(float, float, float)’

please help

You don’t need the “,”. If you remove it, your “real” error shows up which is on line 13 of your code.

You have to reference the Rigidbody which means that you have to assign a specific Rigidbody to your script. I suppose that you put your script on an object with a Rigidbody. You can simply reference it by using

GetComponent().AddForce(100 * Time.deltaTime, 0, 0);

Let me know if you still have trouble.