Toggle menu bar visibility in MacOS 26 Tahoe

Below is my current code but it doesn’t seem to work at all…
If possible could anyone help me fix it, pretty please!!!

use AppleScript version "2.8"
use scripting additions

-- Open the Menu Bar pane
do shell script "open 'x-apple.systempreferences:com.apple.ControlCenter-Settings.extension?MenuBar'"

tell application "System Events"
	tell application process "System Settings"
		set frontmost to true
		
		-- wait for the window & scroll area to exist
		repeat until (exists window 1)
			delay 0.1
		end repeat
		set w to window 1
		repeat until (exists scroll area 1 of w)
			delay 0.1
		end repeat
		set sa to scroll area 1 of w
		
		-- find the (unnamed) popup by its value, anywhere inside the scroll area
		set p to missing value
		repeat 200 times
			try
				set p to first pop up button of (entire contents of sa) ¬
					whose value is in {"Never", "In Full Screen Only", "On Desktop Only", "Always"}
				exit repeat
			on error
				delay 0.1
			end try
		end repeat
		if p is missing value then error "Could not locate the pop-up button. Check Accessibility/Automation permissions."
		
		-- choose the other setting (Never ↔ In Full Screen Only)
		set curVal to value of p
		if curVal is "Never" then
			set targetItem to "In Full Screen Only"
		else
			set targetItem to "Never"
		end if
		
		try
			perform action "AXScrollToVisible" of p
		end try
		perform action "AXPress" of p
		delay 0.2
		click menu item targetItem of menu 1 of p
	end tell
end tell