error CS0116 Runner Ground movement issue

So im trying to create a runner game and teach myself c# at the same time (stop laughing, its easier for some to learn when its in practice) but i get the following error message:

GroundMovement.cs(5,7): error CS0116: A namespace can only contain types and namespace declarations. I think the errors are on line 5 (float speed) and 7(//Offset the material texture at a constant rate) (again, stop laughing) b ut i cant figure out what im doing wrong. the script wont attach to the objects

using UnityEngine;
using System.Collections;

//Material texture offset rate
float speed = .5f;

//Offset the material texture at a constant rate
void Update () {
	float offset = Time.time * speed;                            
	renderer.material.mainTextureOffset = new Vector2(0, -offset);

Thanks a million guys!!!

you need to put your code/variable declarations in a class if you’re using c#.

when you create a new script, it’s already in the template. why did you delete it? i’d recommend some tutorials until you get the hang of the basics.