I’ve been working with Mouse object basically my entire time developing, but I have noticed for some time, that on roblox docs, mouse is called a “legacy object” and basically the only reason why its not deprecated is because of how much its used.
As stated here: “it remains supported because of its widespread use”
There is also stated that you should use UIS or CAS instead. So my question is:
If I would completely stop using mouse object, how could I get things like:
Mouse’s current position on screen
Window size in pixels, since the only “non dirty” way is to get the viewSize property of mouse
Mouse’s origin, probably the most important property used for mouse raycasting, but I absolutely don’t know how I could get its origin any other way
Maybe I am just blind and overlooked something, but are there any alternatives for actual mouse object?
Yes, mouse is considered a legacy object. For a while UserInputService and ContextActionService have been a better equipped option for everything input related. So for any input detection I encourage the use of the two. Both services are also better for cross platform development.
Almost everything mouse does is also available in UIS and CAS.
local vector2 = UIS:GetMouseLocation() -- relative to the top left corner
There’s also GetMouseDelta and other methods you can find in the docs.
camera.ViewportSize. If you’re looking for safe area size, I’d probably create a ScreenGui with IgnoreGuiInset set to false and an invisible frame scaled (1,1) inside. Then I could get the absolute size of the frame. At least that’s how some default scripts take the safe area size, such as dynamid thumbstick controller.