Hi. It sounds like you’re actually just asking how to do a find/replace. Assuming there’s no more than one of those strings in any given line, something like this could work:
tell application "BBEdit"'s window 1
tell line (selection's startLine)
if contents contains "true" then
replace "true" using "false" searching in it options {showing results:0, returning results:1}
else
replace "false" using "true" searching in it options {showing results:0, returning results:1}
end if
end tell
end tell