[URGENT] How to detect if player is actually on the image itself?

I’m making an admin panel but the only main issue I have right now is the way its opens. The hitbox of the images is a square on Roblox so the hovering breaks the UI effects.

Example of the hitbox: (Blue boxes are the hitbox)

I want to detect if the player is actually on the image and not the invisible space of the image. Is that possible, if so could someone help me here?

Since your UI is radial, check if the mouse is close enough to the center of the UI, but not too close. This will easily let you determine if you’re pointing on the image instead of, well, not the image.

local mouse = game.Players.LocalPlayer:GetMouse()
local ui -- Radial Menu
local min,max = 25,50 -- Start and End range in pixels
local function MouseOnRadialMenu()
	local uicenter = ui.AbsolutePosition + ui.AbsoluteSize / 2
	local mousecenter = Vector2.new(mousecenter.X,mousecenter.Y)
	local distance = (uicenter - mousecenter).Magnitude
	return min <= distance and distance <= max
1 Like

Good idea but then what about the long edges of each button?

I added code to my last reply. It should return true if your mouse is laying on the radial menu, and not empty space.

1 Like

I’ll try it thanks for the fast response!

This is the code for the radial menu but I’m not sure if I can use this for the image.

If you want to check if the mouse is on an image, you can use the MouseEnter and MouseLeave events for the image.

That’s not accurate though, it’ll detect the invisible hitbox which in my case overlaps with the other UI hitboxes, causing it to go crazy.

It worked perfectly, thanks for the quick response yesterday!

1 Like

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