Destroy player GameObject on build freeze

Hi, I’m currently doing a game in Unity and I have a question regarding the destruction of my player object.
Currently I’m destroying the player with

public void PlayerDeath() { isDead = true; GetComponent<ScoreController>().SetEndLevelScore(); GetComponent<ScoreController>().SetTotalScore(); //ParticleSystem intantiatedParticle = Instantiate(deathParticle, transform.position, transform.rotation) as ParticleSystem; Debug.Log("Removing camera parent"); Camera.main.transform.parent = null; sceneLoader.GetComponent<SceneLoad>().StartCoroutine("LoadScoreScreenAfterDelay"); Debug.Log("Destroying player object"); Destroy(gameObject); Debug.Log("Player object destroyed"); }
Now this works when I use it in the editor: the player is destroyed, the main camera shows the scene for a few seconds and then the scene changes to the score scene. As you can see:

However, this is not working as it should when I’m playing the game from the built version. In this case the player GameObject model is still there, and the scene is frozen (the projectiles won’t move anymore) as shown here:

This also happens if I use gameObject.SetActive(false); instead.

Anybody can tell me why it’s not working on the built game but it is on the editor? Thanks!

Try using Time.timeScale = 0;
if it’s set to 0, it freezes everything. then 0.5 is half speed and 1 is normal speed

Is the camera attached to the player? If yes, try detaching it and have it as a separate game object.
I recommend that you have a reference to the camera that follows the car in the game and remove it’s parent, as you’ve been trying to do so in your script, because “Camera.main” might go through some malfunctioning but I’m not pretty sure about that as I don’t have any information about your scene.