Help with hover info system

Hello fellow robloxians
I am working on an inventory system, and one of the major parts of that is an information display.
Like this:
image

But, there is a bug in my game where the hover info box will go off the screen.
like this:
image
(also yes that is an eyeball)

So, is there a way I can detect if the player’s mouse is on the left, or right sides of the screen, so i can rotate that box to the opposite side? (eg, the player’s mouse is on the right, therefore the box will show off to the left)

Thanks! :grinning:

You can play around in Studio find which X positions (scale) make the frame go out of screen. Then you can make a script to check if the frame’s position is higher/equal to those positions you found. (That’s for the right side. For the left side, you would check if it is lower/equal to.) I hope this helps.

1 Like

You can get the player’s mouse using Player:GetMouse(), then the property Mouse.X will determine the mouse’s screen position horizontally in pixels. Next, you can use the Mouse.ViewSizeX property and if you divide that by 2, you can determine which side of the screen the mouse is on.
Something like this:

local Mouse = game:GetService("Players").LocalPlayer:GetMouse()

Mouse.Move:Connect(function()

if Mouse.X < Mouse.ViewSizeX / 2 then

print("Left")

else

print("Right")

end

end)
1 Like

Thank you! Here is the result:
This helps a lot with ui readability
image
image

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.