I'm trying to make a mill with a fan that spins on the side (See screenshots below). I've always been horrible at CFrames, they're a bit too complex for me. They're my downfall, and I can never find solutions. The wiki definitely doesn't make it any easier.
Here's the code that makes the fans spin on the mill.
while true do wait() for i = 1,360 do script.Parent.Fan1.CFrame = CFrame.new(script.Parent.FanMiddle.Position) * CFrame.Angles(0,0,math.rad(i)) * CFrame.new(0,0,0) script.Parent.Fan2.CFrame = CFrame.new(script.Parent.FanMiddle.Position) * CFrame.Angles(0,0,math.rad(i) + math.rad(90)) * CFrame.new(0,0,0) wait() end end
So at first I thought everything was working fine: http://prntscr.com/hun1pi
But then when I rotated the mill: http://prntscr.com/hun1zj
The fans don't spin at the correct angle when I rotate the entire mill. How do I fix this?
Instead of doing that, you could weld the blades onto the rotor, and then spin the rotor. To weld something it'll look like this:
local weld = Instance.new("ManualWeld") weld.Parent = a weld.C0 = a.CFrame:inverse() * b.CFrame weld.Part0 = a weld.Part1 = b if not (...) then a.Anchored = false end b.Anchored = false
Here's the article: Welds