Illustrator script failing to select characters

This likely sounds vague. I have a script that opens existing .ai files and then makes several changes to the document across multiple layers. It last was executed in 2021 on the latest Adobe CC Illustrator version. I’m now looking at some older files that need updating and we’re running Illustrator 28.x and the following function is failing on the line set startFontUsed to

I have a function that handles swapping the fonts used for all the text in the document. Previously it was handled with this

tell application "Adobe Illustrator"
	tell document 1
		set fontNameSwapList to {{"Helvetica", "SFProText-Regular"}, {"Helvetica-Bold", "SFProText-Bold"}}    		
		repeat with i from 1 to count of fontNameSwapList
			set startFont to (item 1 of item i of fontNameSwapList)
			set endFont to (item 2 of item i of fontNameSwapList)
			
			set startFontUsed to (every character of every story whose properties contains {text font:text font (startFont)})
			if startFontUsed ≠ {} then
				set text font of (every character of every story whose properties contains {text font:text font (startFont)}) to text font (endFont) of application "Adobe Illustrator"
			end if    			
		end repeat
	end tell
end tell

Raw source:
get every «class cha » of every «class cSTO» of «class docu» 1 whose «property pALL» contains {«class cTXf»:«class cTXf» “Helvetica”}
Error: Internal error (1200)

Maybe the object model changed? I feel silly as I cannot even recall how to work backwards to find a solution. I did try an earlier version of Illustrator from 2023 and that’s also showing the same error.

Thoughts?

It’s a terminology clash between font and text font.

Try this:

tell application "Adobe Illustrator"
	activate
	
	tell document 1 to set theChars to (a reference to (characters of stories whose name of (text font of it) = "Helvetica"))
	if theChars ≠ {} then set text font of theChars to text font "SFProText-Regular"
	
	tell document 1 to set theChars to (a reference to (characters of stories whose name of (text font of it) = "Helvetica-Bold"))
	if theChars ≠ {} then set text font of theChars to text font "SFProText-Bold"
	
end tell

Thank you for the reply. I’ll try working out the replacement in my script and see how this goes. When the entire function finally skips and replaces as expected I’ll post back.