Why does both my input run instantly instead of line by line

when i press space my first if function works but my second if function also executes but why.
how do i make so that only the first if function work but the second doesnt

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

public class Inputtest : MonoBehaviour
{

bool paused;
// Update is called once per frame
void Update()
{
if(Input.GetKeyDown(KeyCode.Space))
{
Debug.Log(“clicked space”);
paused = true;
Debug.Log(paused);
}
if(paused & Input.GetKeyDown(KeyCode.Space))
{
Debug.Log(“cliked space”);
paused = false;
}
}
}

Because… when you get to the next if statement, pause is true, thus it will execute.

You want to use else if, and you also want to check paused is false too.

if(!paused && Input.GetKeyDown(KeyCode.Space))
{
    Debug.Log("Clicked Space");
    paused = true;
    Debug.Log(paused);
}
else if(paused && Input.GetKeyDown(KeyCode.Space))
{
    Debug.Log("Clicked Space");
    paused = false;
}

Also you generally want to use && rather than & 99% of the time.

Also use code tags next time, please.

Thanks man it works