We have UIS:GetMouseLocation() as well as mouse.X/mouse.Y to tell the coordinates of the mouse while it’s within game window bounds, however it does not tell us if it leaves them.
There’s the events UIS:WindowFocusReleased and UIS:WindowFocused, but those only work if the player clicks while the mouse is off the screen.
Is there something to tell that the mouse has left the screen, but the player has not yet clicked off the screen?
That won’t work, that’s only for UI. Even if you do make a UI that’s maximum sized, it won’t work, since when your mouse leaves the window, it doesn’t track the mouse anymore from there unless it’s back in the frame.
This is impossible I think, since there’d be a script for an anti-tab-out thing
You can use Mouse.X and mouse.Y with workspace.CurrentCamera.ViewportSize which will give the screen size in pixels and if the mouse position is larger, then it left, is that what you Meant?
I mentioned that in my post - it only works if the player clicks off the screen, not if it’s outside window bounds but the player hasn’t yet clicked off.
Not the best solution, but I guess FullscreenChanged event could be used to force fullscreen - making it so the mouse can’t move outside of window bounds, combined with WindowFocusReleased to catch any alt+tab stuff.
Hmm actually use the focus released and add a function which detects if he click alt + tab or windows + tab or windows + ctrl + left / right arrow keys
I meant use a function to check if he clicked the button combinations and in the same time have the focus released, like that, you covered every possible way of him tapping out
When they tab out, WindowFocusReleased is triggered.
My problem is I have it so the camera moves as the mouse approaches the sides of the screen, but if you move it to windows taskbar then WindowFocusReleased doesn’t trigger until you click on the taskbar - but it’s not updating the mouse position while it’s past the bounds and therefore continues moving based on the last position of mouse.Y which if they move it fast enough misses the edge camera movement entirely.
The problem is moreso that it doesn’t start moving because it doesn’t know the mouse is past screen bounds. Basically imagine you have it at position 1400, but screen movement starts at 1450, and they move it so the next frame it’s off-screen - the screen movement never started although it probably should have.
This isn’t a problem in fullscreen mode because it can’t move past screenbounds though, so I can make it so that feature is only included if fullscreen mode is enabled.