So I’ve been working on a circle positioning system and I’m having a bit of coders block
the goal is to center a half circle in front of the player
^ this is my issue
Code
local POINTS_TO_GEN = 10 -- points/parts to generate
local RADIUS = 7 -- size of the half circle
local CIRCLE = math.pi -- radius of a circle (half of a circle)
local Part = Instance.new("Part")
Part.Anchored = true
Part.Size = Vector3.new(1, 1, 1)
local Parts = {}
local Colors = {}
local module = {}
function module.DeletePoints() -- Cycles through generated points (parts) and deletes them
for i = 1, #Parts do
Parts[i]:Destroy()
end
end
function module.GeneratePointColors() -- just vanity
for i = 1, POINTS_TO_GEN do
Colors[i] = BrickColor.Random()
end
end
function XandZ(angle)
local x, z = math.cos(angle) * RADIUS, math.sin(angle) * RADIUS
return x, z
end
function module.GeneratePoints(CCFrame) -- CCFrame is HumanoidRootPart CFrame
if #Parts > 0 then module.DeletePoints() end
for i = 1, POINTS_TO_GEN do
local angle = i * (CIRCLE / POINTS_TO_GEN)
local x, z = XandZ(angle)
local NewPart = Part:Clone()
NewPart.CFrame = (CCFrame * CFrame.new(x, 2, z)) -- point (part) positioning
NewPart.Parent = workspace
NewPart.BrickColor = Colors[i]
table.insert(Parts, NewPart)
end
end
return module
I’ve googled and researched for a while but couldn’t find a way to position the half circle the way I want
any help is appreciated