Why does it say "CS1002 ; Expected"?

So i’m new to coding and would like some help for my first script. It says that it expected a “;” but i don’t know where the problem is. Can anybody please help me?

This is my script

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

public class Movement : MonoBehaviour
{
Rigidbody rb;
// Start is called before the first frame update
void Start()
{
; rb = GetComponent();
}

// Update is called once per frame
void Update()
{
; Rigidbody OnMouseDown Velocity = Vector3.forward;
}
}

Food for thought:

  • When posting code in the forum, please use Code Tags to make it more readable - here’s how:
    Using code tags properly

  • While getting an error, you can actually see on which Line the error happened. Check the Console Window (top menu: Window > General > Console) - the text is usually something like this: [XT:IM:EX] (LINE NUMBER, ANOTHER NUMBER).

Now, onto your issue: Those semicolons at the beginning of each line are wrong. Remove them and the script should work fine. Actually, forget that part.
.

I’m not too sure about that line though, even if you take away the semicolon at the beginning. I’m also not sure what they wanted to say with this line though.

And obviously, what is this doing in the Documentation forum?

Yeah, obviously, that Rigidbody OnMouseDown Velocity = Vector3.forward; line is total bollocks :eyes: I- probably shouldn’t visit this forum when I’m half-awake…

As for why it’s in the Documentation forum? No idea. Do we still have mods around here?

@OP Take a look at the Documentation pages for OnMouseDown and Rigidbody.velocity.

And obviously, what is this doing in the Documentation forum?[/QUOTE]

I don’t know where to get help with issues yet, sorry.

This code cannot work without throwing errors; Only put semicolons at the end of lines, not at the beginning with a space. Like Mairi said, read the doc. How I Would Write the Code

This is works best for simple usages like that:

using UnityEngine;
public class Movement : MonoBehaviour
{
    Rigidbody rb;
    
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }
    
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
            rb.velocity = Vector3.forward;
        else
            rb.velocity = Vector3.zero;
    }
}