Restarting the game Error

The game that I am creating is kind of like a 3d dino game with the player dodging the fences that they are racing towards. I wanted to make it so that whenever they push R the game would restart, and I got that to work but whenever the player pushes R, the players jump Hight for some reason starts to drop every time that they push R. Any ideas what might be going on? This is the code that I am using to restart:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Restart : MonoBehaviour
{

void Start()
{

}

// Update is called once per frame
[System.Obsolete]
void Update()
{
    if (Input.GetKeyDown(KeyCode.R))
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    }
}

}

Thanks!!

Have you added this scene in the build settings ?

Yes i think i did