Problem with Creating a Toggle-able Auto-clicker

I’m attempting to create a project that allows me to toggle on and off and auto-clicker using the keyboard. I expected this to be quite easy to make, given that I can create a toggle easily, and I can detect key presses easily. For some reason I couldn’t get the code to work right, it can toggle to the clicking mode, but then I can’t turn it off. Thanks!

Here is my current code:

import keyboard
import time
from pynput.mouse import Button, Controller
toggle = False
variable = False

mouse = Controller()

while True:
    if keyboard.is_pressed('t'):
        variable = True
    else:
        variable = False
        
    if variable == True:
        if toggle == False:
            toggle = True
        elif toggle == True:
            toggle = False
    if toggle == True:
        mouse.click(Button.left, 1)
        time.sleep(0.01)