There are 2 parts. A weld is connected both parts with the Red Part being the Part0 and Grey Part being Part1.
When I rotate the part with the code: workspace.RedPart.Weld.C0 = workspace.RedPart.Weld.C0 * CFrame.Angles(math.rad(-1),0,0), the red part acts like a pivot due to a 6 studs C0 offset between both parts. Is it possible to rotate the grey part locally with math?
This is the desired outcome that I want, but how to do it with code and setting the C0 of the weld?
while true do
local dt = task.wait()
local additionalRotation = CFrame.Angles(math.pi/2*dt,0,0)
additionalRotation = motor.C1:Inverse()*CFrame.Angles(math.pi/2*dt,0,0)*motor.C1--magic trick
motor.C0 *= additionalRotation
--part1.CFrame * C1 == Part0.CFrame * C0 --how welds work
--Let C0 be equal to C0*someCF
--C0 = normal C0 before anything was changed
--someCF is the additionalRotation we want to apply to the Part1 CFrame via CFrame multiplication
--because the weld formula is maintained someCF is added to both sides
--part1.CFrame * C1*someCF == Part0.CFrame * C0*someCF
--To apply rotation to Part1CFrame and not it's C1 we inverse it to cancel out the C1
--Apply this both sides as well
--part1.CFrame * C1*C1:Inverse()*someCF == Part0.CFrame * C0*C1:Inverse()*someCF
--part1.CFrame *someCF == Part0.CFrame * C0*C1:Inverse()*someCF
--we want to maintain original C1 offset so we add that in
--part1.CFrame *someCF*C1 == Part0.CFrame * C0*C1:Inverse()*someCF*C1
--Overall C0 change we need to set to to apply someCF to Part1 CFrame
--C0 = C0*C1:Inverse()*someCF*C1