Help with click and drag camera feature

Hi, I’m making an RPG game with a click and drag camera system, for this I have to set the mouse to visible, and everything seems to work fine but only once, as soon as I stop holding down the right mouse button the game stops capturing the mouse meaning I can move it out of the window, the click and drag system also only works when I hold down the left mouse and the right mouse buttons at the same time.

I’ve only gotten it to work with a really crappy workaround

I really want a way to solve this without having to use an event tick on the player controller and I also feel like this may cause other bugs down the line I might want to avoid.

This is the click and drag system I’ve been using