Hi, I'm fairly new to PrimaryParts and the usage of them, or physics in general when it comes to scripting. I wanted to try out a wind turbine but I had become so confused, as each wing of the turbine would spin in circles instead of along the base point of the turbine.
The gyazo is here: gyazo
My code was this:
local pp = script.Parent pp.Rotate1.PrimaryPart = pp.Rotate1.MeshPart pp.Rotate2.PrimaryPart = pp.Rotate2.MeshPart pp.Rotate3.PrimaryPart = pp.Rotate3.MeshPart a = 0 while wait() do pp.Rotate1.PrimaryPart.CFrame = pp.Rotate1.PrimaryPart.CFrame * CFrame.Angles(0, 0.005, 0) pp.Rotate2.PrimaryPart.CFrame = pp.Rotate2.PrimaryPart.CFrame * CFrame.Angles(0, 0.005, 0) pp.Rotate3.PrimaryPart.CFrame = pp.Rotate3.PrimaryPart.CFrame * CFrame.Angles(0, 0.005, 0) wait() a = a+3 end
and the hierarchy was this: here
Instead of doing all the math, why not rotate the entire model together?
This function of Models named SetPrimaryPartCFrame()
can change the CFrame of a primary part and all of the other parts in the model according to that original movement, so all the parts move together in unison.
script.Parent:SetPrimaryPartCFrame(script.Parent.PrimaryPart.CFrame*CFrame.Angles(0,math.pi,0))
You should probably tab or indent in your code to make it easier to read!
local pp = script.Parent a = 0 while wait() do pp:SetPrimaryPartCFrame(pp.PrimaryPart.CFrame * CFrame.Angles(0, 0.005, 0)) wait() a = a+3 end
Click here to see what it looks like in game: * Gif 1 * Gif 2
Hope it helps!