I intend on making a GUI whose buttons will be thirds of a circle. I don’t fully understand how I would be able to detect a MouseOver for this, or a MouseClick. I also don’t fully understand how I would get it to tween out, kind of like this:
You are merely saying to tween it. I know I have to tween it, but I want to avoid breaks in the smoothness and continuity. Tweening it based on the Top Left Corner will merely muck up the illusion of a 1/3 divided button. I showed quite clearly on my example.
Maybe you could use a seperate third behind the “default” one, and tween it when the default is hovered over, to make it appear the default one is expanding.
Alright, since nobody else wants to provide useful information, allow me.
What you’re trying to create is called a radial menu. This implementation takes 3 ImageLabels, each with the same image but rotated 120° from each other. Take an image like this (but with a transparent background, of course) and cut away any of the 2 thirds.
(I created this by simply dividing a circle into thirds in Photoshop)
You’ll end up with this:
This will be what you upload to Roblox and use in your ImageLabels. Setup your 3 ImageLabels such that they are each anchored to their center (0.5, 0.5) and positioned in the center of their parent frame, like this:
Because they are all anchored at their centers, resizing any of them will cause them to resize outward from the center, like so!
Now unfortunately the MouseEnter/MouseLeave events won’t cut it for detecting mouse hover in this case. However, with some vector math you should be able to figure out which button is being hovered over by figuring out the angle between the up vector in 2d space (0, 1) and whatever direction the mouse is from the center. This module has a function for figuring this out in 3d space which can be easily adapted to 2d space.
Bit of a bump, but I’ll provide more info as requested. The function you want to use is VectorUtil.AngleBetweenSigned()
The 3 parameters you want to pass to it are Vector3.new(0, 1, 0) and (mousePosition - screenSize / 2).Unit, but you’re going to want to convert this to a Vector3 with 0 as the Z coordinate. The last parameter you want to give the function is Vector3.new(0, 0, 1). The return value of this function will give you the angle that the mouse is currently at from the center of the screen. The reason why this works is because 2d space is just 3d space with no Z coordinate, which is the same as a Z coordinate of 0.
Mouse position can be gotten from UserInputService:GetMouseLocation() and screen size can be gotten from workspace.CurrentCamera.ViewportSize.
Of course, if your radial menu is not at the screen’s center you’ll need to transform the mouse position accordingly.