How to limit cursor movement and scale it to the screen?

I’ve recently become interested in forcing the movement of the mouse into a box on my screen, To explain, I’ll use an example, aka this picture below. I can only move the red dot [ which is the mouse/cursor ] within the black box. No matter what, I can’t move the mouse within the white space. Make sense? I hope so. I’m trying to replicate this image within my game, of course, not the gui, but the function of it.

Picture below.

Summary

So what’s the issue? I’m clueless of how to get the distance from the black box to the edge of the monitor screen to be even, so the black box is perfectly center and scaled to the monitor/device, while also scaling the cursor as well. I have a mock up script for you to see what I mean.

CursorBox.rbxl (56.6 KB)

Trying to remake @TEARAPARTJAMES dog is hungry Cursor movement. Video related to what I’m trying to make with the cursor. https://www.youtube.com/watch?v=Jgv6crXWIuw

You can insert a BillboardGui inside the part and read it’s AbsolutePosition property.

The Camera object also has a bunch of properties that let you read the size of a user’s monitor.

Both these things could be used in combination to calculate how far away something is from the border of a screen but that’s about as far as I can get now.

2 Likes

I currently don’t use any parts, so what do you mean?

I’ll look into that, thanks.

How so?

For anyone who’s struggling with this, Try turning on “IgnoreGuilnset” in the ScreenGUI, It may fix your problem.

1 Like