Way to tell if the mouse is currently free due to a GuiButton with Modal enabled?

In a game where your mouse is locked most of the time, usually due to being in First Person, I want to be able to tell if the player’s mouse is free due to a GuiButton with Modal enabled being visible.

I’ve been combing through Roblox’s API documentation and I cannot find anyway to reliably distinguish this from the mouse just being normally unlocked (ie: Player is in Third Person, or otherwise a state is forcing MouseBehavior to default).

I’m pretty sure there isn’t a way to do this, but please enlighten me if you know a way to do so without relying on UserInputService.MouseBehavior.

This is not really possible without detecting if an enabled ScreenGui has a GuiButton with Modal enabled. There is no perfect way to detect this at the moment.

You can try this: If your game starts out as locked to the screen, then you can try to save the original mouse X and Y position when they load in, and just check if its at the center by doing mouse.X == originalMouseX and mouse.Y == originalMouseY

This is what I used.
It worked perfectly with RenderStepped.

last second edit: I think this can be flawed if the mouse is somewhere else when they load in (via being alt tabbed)

edit 2:
I formulated this code, it requires the use of MouseBehavior which is not what you’re looking for because you said “without relying on UserInputService.MouseBehavior”

but without mousebehavior this is impossible, you can only do it, with it

this is the closest code I got to accomplishing that idea (anti-alt tabbed I am assuming)

task.spawn(function()
		if uis.MouseBehavior == Enum.MouseBehavior.LockCurrentPosition or uis.MouseBehavior == Enum.MouseBehavior.LockCenter then
			if not updatedIt then
				updatedIt = true
				originalMouseX = mouse.X
				originalMouseY = mouse.Y
			end
		end
		if mouse.X == originalMouseX and mouse.Y == originalMouseY then
			uis.MouseIconEnabled = false
			gameGui.CROSSHAIR.Position = UDim2.new(0, mouse.X, 0, mouse.Y);
		else
			uis.MouseIconEnabled = true
		end
	end)