Player getting stuck when i respawn efter death in 2d

so i just made my player respawn efter getting killed by spikes and it works! but only one problemis that hes getting stuck where ever i set the Respawn object, it doesnt let me run or anything im just stuck in the air.

i did add a

 transform.position = GameObject.FindWithTag("Respawn").transform.position;

and the “respawn” is the gameObject were im going to spawn.


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour

public CharacterController2D controller;
public Animator animator;

public static float healthAmount;

float horizontalMove = 0f;
public float runSpeed = 40f;
bool jump = false;
bool crouch = false;

private void Start()
    healthAmount = 0.70f;

// Update is called once per frame
void Update()
    horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed; // This is equal to -1 or 1, when A is pressed it's equal to -1 and D is equal to 1

    animator.SetFloat("Speed", Mathf.Abs( horizontalMove));

    if (Input.GetButtonDown("Jump"))
        jump = true;

        animator.SetBool("IsJumping", true);

    if (Input.GetButtonDown("Crouch"))
        crouch = true;
    else if (Input.GetButtonUp("Crouch"))
        crouch = false;

    if (healthAmount <= 0)
        transform.position = GameObject.FindWithTag("Respawn").transform.position;


You should debug your code while running to check why is not moving. Maybe you also need to reset the jump, crouch and movement variables to make sure the player is at “initial state”.

But as i said, best is to debut the code and check what is not doing what you expect.