Applescript inside FM not working as expected

I'm running Sonoma 14.7.1 and BTT 4.947 on a macboook pro 2021 16 inches m1 max.

I have this applescript running in a FM. This FM is always shown when System Settings is the frontmost app:

The applescript changes the color and the text of the FM depending if the app "SysPref AntiAction" is running or not.

Clicking the FM run/quit that application.

The problem I am having is that the color and the text of the FM is never updating while the System Settings is the frontmost app.

But FM color and text are updated if I switch the frontmost application and go back to System Settings.

This applescript was working fine before. Maybe I have to do some modification to the applescript configuration?

What is SysPref AntiAction ?

In general running apple scripts every that often (every 0.1 seconds) can be problematic. Usually it doesn't break but it can cause delays and very high cpu usage.

You could try replacing the if with BTT's is app running function

tell application "BetterTouchTool"
	set isRunning to is_app_running "SysPref AntiAction"
	if isRunning then
		
	else
		
	end if
end tell

What is the script result if you run the script in BTT while system settings is active? (you can run it without activating BTT by cmd+clicking the run script button)

SysPref AntiAction is a small app that I have done. It allows/deny to other apps/scripts that I have done to make changes in System Settings while this is running.

Before starting the thread I tried higher repetition time (0.5 and to 1 sec), but the problem was not fixed.

I didn't know the trick of cmd+click, thx!
The script result is correct, but the floating menu is not updating. Here you can see the floating menu in red with the text NOT RUNNING, while the script result is blue and text is RUNNING (delay time is 0.5):

I have replaced the script with your code and it works fine.

Then I have replaced your code with my previous code and it works like a charm.

So now, after replacing the code, it's working correctly. What I could say? Thank you for fix it !!

Ah weird. There have recently been some fixes to scripts, maybe there was still something old cached.