mouse.ViewSizeY not working properly? Any alternative methods to fix this?

I used this script for testing purposes:

while wait() do
	print(mouse.y/mouse.ViewSizeY)
end

What is expected: When my mouse is all the way at the top, it should print 0. When my mouse is all the way at the bottom, it should print 1. Results should be the same no matter the viewport size.

What actually happens: When my mouse is all the way at the top, it prints -0.011320754716981. When my mouse is all the way at the bottom, it prints 1.1320754716981. Results will vary depending on viewport size.

For some reason, doing print(mouse.x/mouse.ViewSizeX) works perfectly for the X position.

Please tell me how I can fix this!

One extra thing I noticed: When I print (mouse.y) and put my mouse to the bottom of the screen, it prints 300. When I print (mouse.ViewSizeY) it prints 265. Is this a glitch? I’m wondering if it has anything to do with the topbar.

Mouse.Y is affected by topbar inset, and I’m not even sure how Mouse.ViewSizeY works because it looks like its offset by 2x the topbar size. You can use UserInputService:GetMouseLocation() and CurrentCamera.ViewportSize to get the real mouse location and screen size respectively

1 Like