Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make these parts spin along with my mill?

Asked by 6 years ago

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?

1 answer

Log in to vote
0
Answered by
Tomstah 401 Moderation Voter
6 years ago

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

0
So I welded the fans to the rotor. I don't know how to make the rotor spin from the weld though or whatever. Jesse1240 59 — 6y
0
Well you could just use Orientation if it's one part. The premise of weld is it'll just follow the part you welded it to. So just mess with the main rotor and you'll see what I mean. Tomstah 401 — 6y
Ad

Answer this question