Run this in a clean, blank project - see if it works the way you need first. You might be doing or have set up something extra we cannot see - hard to guess. Some template settings perhaps?
At a glance, it seems like an issue with either a Pawn or Mouse Capture but I can’t tell what’s up with this. It’s not a script (that we see) issue.
How’s this on your end?
You may want to have the green option:
The behaviour looks like the red one.