Well, Apple have made a real mess of that! Not only is there extra nesting of elements (expected in the new Swift UI world), they've some managed to create a menu that isn't associated with a process... You'll have to go old-school and select the menu item by simulated typing-and-Return.
Try this script instead:
tell application "System Events"
tell application process "screencaptureui"
tell window 1
tell group 1
tell menu button 1
click
delay 0.1
end tell
keystroke "Remember"
keystroke return
end tell
end tell
end tell
end tell