I’ll keep it short, so you know radial menus right? They’re pretty cool, for the most part they also seem simple, except for one thing about them.

A few good radial menus have these lines in the middle that divide the circle into segments, whether it be 2 items in the menu or 3 or 4, they always seem to perfectly divide the circle depending on the amount of items inside it. I want to know how to do that and I’ve genuinely tried but it always leads back to square one with me scratching my head on how I’m supposed to do the math to position and rotate it all correctly.

This is all being done using GUI Objects, no parts or anything like that.

I think I’m going completely in the wrong direction with all of this however, so I need some help on what I should be doing when it comes to the mathematical stuff.

Here’s an image on what I’m hoping to create, but more white lines get created as more objects get added to the menu.

this might help… i dont know how to apply it or where to use it but you can try something with it. i use it to multiply cframes.

(do this for each section)

``````local radius = 3
local angle = SECTION_NUMBER * (math.pi*2 / #TOTAL_SECTIONS)
local x = math.cos(angle) * radius
``````
1 Like

Ah, that seems sort of similar to what I’m trying currently.

``````local RADIUS = .35
local NUM_OPTIONS = 3
local ANGLE_OFFSET = 90

-- Create a screen and frame for the menu

-- Define position and size for the menu frame in both opened and closed states
local menuOpenPosition = UDim2.new(0.283, 0,0.026, 0)
local menuOpenSize = UDim2.new(0.565, 0,0.947, 0)
local menuClosedPosition = UDim2.new(.5, 0, .5, 0)
local menuClosedSize = UDim2.new(0.005, 0, 0.005, 0)

-- Define the element for the menu options
local itemTemplate = script.h

local newItem = {}
local label = itemTemplate:Clone()
local line = script.e:Clone()
line.Rotation = #menuItems * (math.pi*2 / #NUM_OPTIONS)
end

for i = 1, NUM_OPTIONS do
local angle = (360 / NUM_OPTIONS) * (i - 1)
local name = "Option" .. i
end
``````

As you can see, when it comes to the line part, I’m sort of really screwing it up, the part where I can put the object in is perfectly fine, it’s just the line that I’m failing to comprehend.

The way that I’m doing it is that I’m using a custom image that’s the same size as the circle, it’s merely just a line that starts at the center and ends at the very right of the image, essentially covering one half of the circle.

1 Like

here is a demo project

and this is the script

``````local amount = 3
local angle = math.pi * 2 / amount
local line = script.Parent.Line
line.Parent = nil

for i = 1, amount do
local lineAngle = i * angle + angleOffset
local clone = line:Clone()
clone.Position = UDim2.new(0.5 + math.cos(lineAngle) / 4, 0, 0.5 + math.sin(lineAngle) / 4, 0)
clone.Rotation = math.deg(lineAngle)
clone.Parent = script.Parent
end
``````
2 Likes

It took a while to adapt the code to my project but holy heck it works almost flawlessly, thank you!

1 Like