Hello fellow robloxians
I am working on an inventory system, and one of the major parts of that is an information display.
Like this:
But, there is a bug in my game where the hover info box will go off the screen.
like this:
(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)
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.
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)