I Can't Figure Out How to Reload a Scene Without Reloading the Player

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class RewindTime : MonoBehaviour
{
public GameObject playerPrefab;
private Scene ThisScene;
void Start()
{
ThisScene = SceneManager.GetActiveScene();

}
void Onstart()
{
var player = GameObject.FindGameObjectWithTag(“Player”);
if (player == null)
{
player = Instantiate(playerPrefab);
DontDestroyOnLoad(player);
}
}
void Update()
{
{
if (Input.GetKeyDown(KeyCode.R))
SceneManager.LoadScene(ThisScene.name);
}
}
}

[/code]

my goal is to reload the scene without reloading the player but the best i can do is create two player
I cant figure out whats wrong with this please help

i hate how the brackets are moved to the left

Hello

There is no opening tag

Christoph

You don’t call OnStart() so this code doesn’t get executed.
Also, why are you instantiating and marking the player undestroyable in the script not related to the player? If the player has already been created and is not marked as undestroyable, then this code will not work and the player will be destroyed.
And Application.LoadLevel() is obsolete. Use SceneManager.LoadScene().

its related to the player because my goal is to reset the entire scene but save eerything about the player and not delete it and i have edited the script to i think reflect your changes and it still is not working

Use code tags

Code tags: https://discussions.unity.com/t/481379 page-2#post-6140955

In your Onstart() method you have no else feature which means if there is a player active in the scene he will be Destroied when reloading the scene