mscOS Ventura: Toggle Function key F1, F2 as standard function keys

I just upgraded to macOS Ventura recently. Previously I had a Keyboard maestro script set for macOS Monterey for turning on the 'Use F1, F2, etc. keys as standard function keys' on the keyboard setting on or off whenever my 'critrix viewer' app is on or not (I used it to work on the window VDI at work)

After upgrading to MacOS Ventura, the location of the check box for 'Use F1, F2, etc. keys as standard function keys' inside the system preference setting has been moved, and my macro no longer works.

Can someone help me with fixing this code to one that would work for MacOS Ventura?
Thank you so much in advance!!!

Please see below for the script:

To turn the standard function key function on:
Execute an AppleScript Action (v10.2)

Execute an AppleScript.kmactions (1.8 KB)

To turn the standard function key function off:

Fn Keys Trigger_Deactivate Macro (v10.2)

Fn Keys Trigger_Deactivate.kmmacros (3.3 KB)

I'm not very good with AS, but System Preferences are now System Settings.
Names within are changed, and functions moved about.

Some help here: Finding System Preferences & Using System Settings in MacOS Ventura

Try this AppleScript

Thank you so much!

I adopted most of the script in the GitHub link you sent me
I never studied coding and this is the best I can do.
I set it to activate when a certain application activates
Able to make the Function key page pop up but unable to make it click the button.
Also it doesn't work when that application deactivates.

it is so close to doing that! Any suggestion?

Activates:
FN Key - Activates - version 2.kmmacros (3.3 KB)

Deactivates:
FN Key - Deactivate - version 2.kmmacros (3.3 KB)