Help Me With My script

So Guys i’m new to unity and programming overall and with my first game script i encountered some issues
i’m trying to use the rigidody physics with already set inputs to create a controllerscript to control the movement of my player

this is my script

public float Speed;
public Rigidbody2D myRigidbody;

// Use this for initialization
void Start () {
myRigidbody = GetComponent();
}

// Update is called once per frame
void Update () {
if (Input.GetAxisRaw (“Horizontal”) > 0f)
{
myRigidbody.velocity = new Vector3(Speed, myRigidbody.velocity.y, 0f);
} else if (Input.GetAxisRaw(“Horizontal”) < 0f)
{
myRigidbody.velocity = new Vector3(-Speed, myRigidbody.velocity.y, 0f);
} else
{
myRigidbody.velocity = new Vector3(0f, myRigidbody.velocity.y, 0f);
}
}
}

the script is Correct and i don’t get any error message but when i run the game althought i press the L/R arrows the player doesn’t move

NeverMind guys Stupid me forgot to attach a number for Speed Value in the inspector
it was 0 so basicaly it was running this line
else
{
myRigidbody.velocity = new Vector3(0f, myRigidbody.velocity.y, 0f);
}

which tell the player to stay still

I’m glad you solved it yourself…
Please take a moment to look at this page for the future on the forums:

It tells you how to insert code on the forums, so that it looks nicer & is easier to read :wink:

Have fun with your game!