Toggle UI question

Hello guys, I am working with the Toggles of the UI system for the first time. But it does not really work as I thought it would.

public void toggleSomething() {
		toggled = true;
	}

This does work, it sets the bool toggled to true and prints out to the console, but once it is clicked again or rather toggled back on, it does not set it to false.

I can’t find a way to do it.

I thought something like

public void toggleSomething() {
    		if(toggleSomething.isOn) {
                  toggled = true;
}else {
  toggled = false;
}
    	}

But nothing is working, seems hard to find anything online about it too. as
public Toggle name
does not work either it just errors something like Toggle is unknown.

Thanks for any help

void Toggle()
{
toggled = !toggled;
}