Stop player sprint after amount of time (2D) (c#)

Hello, I’ve been messing around with this for a while, trying to get my Player to not be able to sprint after 2 seconds. I’ve looked at coroutines and wasn’t able to figure it out (I’m a Beginner) Here is my script and hopefully someone could help me out! Thanks
using UnityEngine;
using System.Collections;

public class PlayerMove : MonoBehaviour {
	
	public float speed = 10, jumpVelocity = 10;
	public LayerMask playerMask;
	Transform myTrans, tagGround;
	Rigidbody2D myBody;
	public bool canMoveInAir = true;
	public bool isGrounded = false;
	
	// Use this for initialization
	void Start () {
		
			myBody = this.GetComponent<Rigidbody2D>();
			myTrans = this.transform;
			tagGround = GameObject.Find (this.name + "/tag_ground").transform;
			
		
	}
	
	
	
	// Update is called once per frame
	void FixedUpdate () {
		
		
		
		Move(Input.GetAxisRaw("Horizontal"));
		if(Input.GetButtonDown("Jump"))
			Jump();
	
	}
	
	public void Move(float horizontalInput) {
		
		
		if(!canMoveInAir && !isGrounded)
			return;
	
		Vector2 moveVel = myBody.velocity;
		moveVel.x = horizontalInput * speed;
		myBody.velocity = moveVel;
		
}

	public void Jump() {
		
			if(isGrounded)
				myBody.velocity += jumpVelocity * Vector2.up;
		
	}
	
	public void Update () {
		
		isGrounded = Physics2D.Linecast (myTrans.position, tagGround.position, playerMask);
		
		if (Input.GetKeyDown(KeyCode.LeftShift)){
			speed = 10.0f;
		
	}
	
		if (Input.GetKeyUp(KeyCode.LeftShift)) {
			speed = 6f;
		}
	}
}

Just add float sprintTime; at the top with the other variables. Then add if (Input.GetKey (KeyCode.LeftShift)) { sprintTime += 1/(1/Time.deltaTime); } into the Update () function. All this is doing is creating a float that will increase only when the player is sprinting. Now just modify the if statement that’s increasing the player’s speed if (Input.GetKeyDown(KeyCode.LeftShift)) and replace it with if (Input.GetKeyDown(KeyCode.LeftShift) && sprintTime <= 2f) what this is doing is just checking to see if the player has already sprinted for more than 2 seconds. Now the last thing you need to do is make sure the speed will reset as soon as the player has been sprinting for more than 2 seconds. To do this, we need to edit the other if statement if (Input.GetKeyUp(KeyCode.LeftShift)) and replace it with if (Input.GetKeyUp(KeyCode.LeftShift) || sprintTime > 2f) Now this will reset the speed if the player has used up their sprint time.

Just a recap, the class should look like:

using UnityEngine; 
using System.Collections;

public class PlayerMove : MonoBehaviour {
	
	public float speed = 10, jumpVelocity = 10;
	public LayerMask playerMask;
	Transform myTrans, tagGround;
	Rigidbody2D myBody;
	public bool canMoveInAir = true;
	public bool isGrounded = false;
	float sprintTime;
	void Start () {
		
		myBody = this.GetComponent<Rigidbody2D>();
		myTrans = this.transform;
		tagGround = GameObject.Find (this.name + "/tag_ground").transform;
	}
	void FixedUpdate () {
		Move(Input.GetAxisRaw("Horizontal"));
		if(Input.GetButtonDown("Jump"))
			Jump();
		
	}
	
	public void Move(float horizontalInput) {
		if(!canMoveInAir && !isGrounded)
			return;
		
		Vector2 moveVel = myBody.velocity;
		moveVel.x = horizontalInput * speed;
		myBody.velocity = moveVel;
		
	}
	
	public void Jump() {
		if(isGrounded)
			myBody.velocity += jumpVelocity * Vector2.up;
		
	}
	
	public void Update () {
		isGrounded = Physics2D.Linecast (myTrans.position, tagGround.position, playerMask);

		if (Input.GetKey (KeyCode.LeftShift)) {
			sprintTime += 1/(1/Time.deltaTime);
		}

		if (Input.GetKeyDown (KeyCode.LeftShift) && sprintTime <= 2f) {
			speed = 10.0f;
		}
		
		if (Input.GetKeyUp (KeyCode.LeftShift) || sprintTime > 2f) {
			speed = 6f;
		}
	}
}