Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to tell if mouse is off-screen?

Asked by
blowup999 659 Moderation Voter
2 years ago

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?

1
Could you create a virtual cursor and make the player lock in first-person view? You could detect their cursor movement by UserInputService:GetMouseDelta() and the actual cursor will never go off-screen, nor the virtual cursor if you script it to not go off-screen. (This is a repost) Xapelize 2658 — 2y

Answer this question