I made a script that closes and opens 8 parts by a 180 degree but need help with pivoting it somehow so it rotates from the end of the part instead of just going back and forth from the origin point, I am struggling with figuring out on how I can achieve this
local rotAngle = 45
local rs = game:GetService("RunService")
for i, part in pairs(script.Parent:GetChildren()) do
local angle = 360/8
if part:IsA("BasePart") then
part.CFrame = workspace.Origin.CFrame * CFrame.Angles(math.rad(angle*i),0,math.rad(45)) * CFrame.new(0,15,0)
end
end
rs.Heartbeat:Connect(function()
if rotAngle == 180 then
rotAngle = 0
end
rotAngle+=1
for i, part in pairs(script.Parent:GetChildren()) do
local angle = 360/8
if part:IsA("BasePart") then
part.CFrame = workspace.Origin.CFrame * CFrame.Angles(math.rad(angle*i),0,math.rad(rotAngle)) * CFrame.new(0,10,0)
end
end
end)