Rotating Three Parts In a Circle

So I’m trying to make a script that makes 3 parts around a circle and then spins them while the radius gets smaller until they all meet in the middle, ive managed to get the first part down but idk how I would get them to all rotate around a circle. (I can figure out the radius getting smaller and smaller I think on my own it’s really just the rotating part I’m having trouble with.)

Here is a visual example of what I want:
Screenshot 2023-06-12 115010

Here is my code so far:

local PartsFolder = {}
		local fullCircle = 2 * math.pi
		local radius = 2
		local RootPartCF = RootPart.CFrame
		local RootPartPos = RootPart.Position
		
		local function getXAndYPositions(angle)
			local x = math.cos(angle) * radius
			local y = math.sin(angle) * radius
			return x, y
		end
		
		for i = 1 ,3 do
			
			local Part = Replicated.Part:Clone()
			table.insert(PartsFolder, Part)
			Part.Name = "Part"..i
			print(Part.Name)
			Part.Anchored = true
			Part.CanCollide = false
			local angle = i * (fullCircle / 3)
			local x, y = getXAndYPositions(angle)

			local position = (RootPartCF * CFrame.new(x, y, - 2)).p
			Part.CFrame = CFrame.new(position)
			Part.Parent = workspace
			
		end		
1 Like

After some time I figured it out for those wondering here it is:

local function calculatePositionC(i, radius)
			local angle = (i + 1) * (fullCircle / 360)
			local x = math.cos(angle) * radius
			local y = math.sin(angle) * radius
			local position = (CFrame.new(x, y + 1.5, - 5)).Position
			return position
		end

		for i = 1 ,3 do
			local MockPart = Instance.new("Part")
			MockPart.Parent = workspace
			MockPart.Anchored = true
			MockPart.CanCollide = false
			MockPart.Size = Vector3.new(1,1,1)
			MockPart.Transparency = 1
			MockPart.Name = "MockPart"..i		
			table.insert(MockPartFolder, MockPart)

		end  

		local function Hope(i)

			local MockPart = MockPartFolder[i]	
			local Angle =  i * 120


			local Mover = RunService.RenderStepped:Connect(function()

				if CurrentlySpinning == false then
					MockPart.CFrame = RootPart.CFrame * CFrame.new(calculatePositionC(Angle, radius))				
				end
			end)

			task.wait(0.6)
			
			CurrentlySpinning = true
			for a = 0,360,12 do
				task.wait()
				radius = radius - 0.02222222222
				MockPart.CFrame = RootPart.CFrame * CFrame.new(calculatePositionC(Angle + a, radius))	
			end	
			CurrentlySpinning = false
			task.wait(1)
			Mover:Disconnect()

		end

		for i = 1, #MockPartFolder do	
			coroutine.wrap(function()
				Hope(i)
				
			end)()	
		end		

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.