Hello, I am trying to make multiple parts move around the player in a circle motion and after it makes a full loop around the player it shoots out and moves until it hits something.
I’ve currently got parts to surround the player in a circle and move with the player but not spin or shoot.
Here is the code: (It goes in StarterCharacterScripts)
local PARTS = {}
local fullCircle = 2 * math.pi
wait(2) -- So we can watch it once we load in
for I=0, 12 do
local PART = Instance.new("Part")
PART.Shape = Enum.PartType.Ball
PART.Anchored = true
PART.CanCollide = false
PART.Parent = workspace
PARTS[#PARTS+1] = PART
end
local function getXAndZPositions(ANGLE, RADIUS)
RADIUS = RADIUS or 5
local x = math.cos(ANGLE) * RADIUS
local z = math.sin(ANGLE) * RADIUS
return x, z
end
for O=0, 360 do
for i, part in pairs(PARTS) do
local angle = i * (fullCircle / #PARTS) - i
local x, z = getXAndZPositions(angle)
local position = (script.Parent.HumanoidRootPart.CFrame * CFrame.new(x, 0, z)).p
part.CFrame = CFrame.new(position)
end
wait()
end
Any help will be greatly appreciated!
Thank you, Zonix.