Can't figure out the math to make GUI frames appear in a circle?
I am trying to make a GUI mini game where there is a circle with frames at random points on it. At the moment I am just trying to get the frames to make a full circle first so I can have something to start working off of to make if function properly
Here is the code I have put it a Script in a GUI as this portion is only the set up and has nothing to do with any mechanics apart from making a circle.
The commented out code was my first attempt in which is cause randomized frames off the GUI
01 | local frame = script.Parent [ "Frame Spot" ] |
03 | local place = Instance.new( "Frame" ) |
04 | place.Size = UDim 2. new( 0.046 , 0 , 0.083 , 0 ) |
05 | place.Position = UDim 2. new( 0.475 , 0 , 0.042 , 0 ) |
08 | place.BackgroundColor 3 = Color 3. fromRGB( 0 , 0 , 255 ) |
09 | place.BackgroundTransparency = 0.5 |
13 | local dec = math.random( 1 , 100 )/ 100 |
14 | local angle = dec*math.pi* 2 |
15 | local radius = frame.AbsolutePosition.X/ 3.4 |
16 | local x 0 = frame.AbsolutePosition.X/ 2 |
17 | local y 0 = frame.AbsolutePosition.Y/ 2.1 |
20 | local x = x 0 +radius*math.cos( 2 *math.pi*i/count)- 50 |
21 | local y = y 0 +radius*math.sin( 2 *math.pi*i/count)- 17 |
22 | local marker = Instance.new( "Frame" ) |
23 | marker.Size = UDim 2. new( 0.046 , 0 , 0.083 , 0 ) |
24 | marker.Position = UDim 2. new( 0 , x, 0 , y) |
25 | marker.Rotation = angle |
27 | marker.BackgroundColor 3 = Color 3. fromRGB( 0 , 0 , 255 ) |
28 | marker.BackgroundTransparency = 0.5 |
At the moment what this code currently does is generate a rough circle but the frames make like an oval shape and just barely miss making a full circle and I am unsure of how I can make them actually turn it into a proper circle as all my attempts have made it much worse
I am using a image to have the frames line up on which is this
https://www.roblox.com/library/3452386899/Images-Repair-minigame
If you need any more information feel free to ask for it and I will supply it to the best of my ability.