How to make a rotating windmill

So, I was wondering how I could make a Rotating WindMill

I have already tried a couple different scripts, including this one

local rotateX = script.Parent.Orientation.X 
local rotateZ = script.Parent.Orientation.Z


while true do
	if rotateX <= 90 and rotateZ == 180 then
		rotateX = rotateX - 1
	elseif rotateX >= -90 and rotateZ == 180 then
		rotateX = rotateX - 1
	else
		rotateX = rotateX + 1
	end 
	wait(0.05)
end
1 Like

You have to change the Orientation itself if you want to rotate it, the X Y and Z parts can only be used for reference.

while true do
	for i = 0, 359 do
		script.Parent.Orientation = Vector3.new(i, 0, 0)
		wait()
	end
end

If this script causes the windmill to rotate the wrong way, you can switch i with one of the zeros in the Vector3.new call, like Vector3.new(0, 0, i) or Vector3.new(0, i, 0).
Edit: If that code crashed your game, add the wait

1 Like

thank you so much! I will try this right now

2 Likes

You could just try using a motor hinge?

2 Likes

so, this worked with the rotation, however, is there a way I could do this with a model?

So, can you explain to me how I would do this?

1 Like

You would have to weld each part in your model to the rotating part and rotate the central part.
However, I would rather use a motor like @LandofLee1620 suggested, along with the welds.

ok thank you for your help guys

robloxapp-20200412-1732402.wmv (497.5 KB)
This keeps happening

Sure!
First go to the model tab in studio and click this button:


Select the hinge and attach it to the different parts like this:
Screen Shot 2020-04-12 at 5.37.03 PM
Go to the properties menu of the hinge constraint and change the actuatorType to motor:

Mess around with the angular velocity (the higher the number the faster it will go. Note: to change directions simply put a negative symbol in front of the number.
The motormaxtorque is higher for how heavy the object was. (In my case I did a water wheel and since it had a lot of parts I made the torque very high).
If the wheel isn’t moving you’ll just have to mess around with the numbers some more.

Hope this helps!

2 Likes

Thank you so much, this will be tons easier!

1 Like

So, I did exactly what you showed me, and it for some reason isn’t turning at all

1 Like

@TSF_Lacker, the reason that happened was that the CFrame script you were using was trying to center it around the center of the windmill blade model. If you select the model with the Move tool, you will see the arrows are pointing around the center of the model and that’s where it will spin.

Also make sure none of the rotating components are Anchored! This isn’t a CFramed model anymore if you are using a HingeConstraint. When using a HingeConstraint make sure the Attachments are at the same location physically. If not they’ll try to move to that location.

And make sure the one Attachment is to the Anchored base part, the other Attachment is on the rotating assembly.

1 Like

ohhh ok so I should un anchor all the blades on the wind mill right?

1 Like

Yes, if it’s supposed to move and you Anchor it you will have problems.

robloxapp-20200412-1802019.wmv (1.3 MB)

ok now its fallen appart

How many Parts in your windmill rotating model?
You could keep them anchored and use a Weld script to weld them together then unanchor them, or if there are only a few Parts use the Weld tool (while in Studio, the first drop-down list that @LandofLee1620 showed you in the image has the Weld tool in it) to connect the Parts.

If your windmill is purely decorative and not expected to be used for gameplay, you should use a Motor6d instead. This will create a constant smooth motion without eating up CPU.
Use this plugin:

Make sure the blades are unanchored and welded together. Set Part0 to the hub of your windmill, Part1 to one of the blades, then use the hub as the pivot. The motor will be parented under the hub where you can change its speed.

2 Likes

@Scottifly is right. I unioned the parts on my water wheel instead of using welds (probably not the best idea but it worked)