Problem with rotating parts

So i am trying to make a model rotate itself and it isnt rotating at all. What I wanted to do is to make the model rotate with all of the parts that are grouped together so that way there are no errors. Here is my script so far:

while true do
	script.Parent.Orientation = script.Parent.Orientation + Vector3.new(1,0,0)
	wait()
end

The part was rotating when i tested this but when I used on the model, it was not working.

1 Like

Because Orientation is not a property of a model.

You have to set a primary part of the model, then change the rotation of the primary part using script.Parent.PrimaryPart.Orientation


This is what the script would look like (this is also an upgraded version that will perform better):

-- >>: Variables
local runService = game:GetService("RunService")

local model = script.Parent

repeat task.wait(1) until model.PrimaryPart ~= nil

-- >>: Main Code
local function Heartbeat(deltaTime)
	model.PrimaryPart.Orientation += Vector3.new(1, 0, 0)
end

runService.Heartbeat:Connect(Heartbeat)
2 Likes

The model isnt moving at all when I tried that

Have you set the primary part to anything?

Did you set the PrimaryPart to the part you want to rotate? It works just fine when I test it.

I checked the model and it does not have a primary part unfortunately so do I simply put a part and rename it to PrimaryPart or does it require more steps?

You just click the PrimaryPart property and click a part in the model.

Also, the code I gave you will bug out a little when the part orientation reaches 90.

Change the script to this:

-- >>: Variables
local runService = game:GetService("RunService")

local model = script.Parent

-- >>: Main Code
local function Heartbeat(deltaTime)
	model.PrimaryPart.Orientation += Vector3.new(1, 0, 0) / deltaTime
end

runService.Heartbeat:Connect(Heartbeat)

If you want to rotate an entire model you need to tween the root part of the assembly! it would be reccomended to use a BodyMover and edit its position to where you want it. It would be wise if possible to make the parts of your assembly either massless or figure out how much force is needed to move the model.
I would reccomend installing the RigEditor plugin. Select first your basepart of the assembly then select everything else at once. At this point you could build moving parts of your assembly and learn about joints and make animations. Either make joints or make welds from the basepart to your entire assembly. At this point you should anchor the part you wish to move if you are just tweening its CFrame or leave it unanchored whilist tweening a bodymover. It is important that you unanchor the rest of the model.
the goal of the tween would be written like this, provided they are x y z rotations. Once you write your tween perhaps you want to loop it. if you do use Tween.Completed:Wait() provided ‘Tween’ is your tween
Root=Model.PrimaryPart
goal={}
goal.CFrame=Root.CFrame * CFrame.Angles(math.rad(0),math.rad(90),math.rad(0))

I’ve clicked the primary part but the primary part is just moving itself, not with the other parts that are in the model

should I make the clock a humanoid or a simple model since im using rigedit? also when I used it, it isnt setting it up.

Im talking about using the RigEditor plugin to open it first select something with a humanoid to activate it then you can select your model the primary part first then all the part descendants and weld them together so they respect that the primary part is the C0 of their weld. and the whole model will move with that part if the rest of the parts of the model are unahcored.

You should be tween the primary parts cframe not the position! Doing so may break the other welds but if you change the CFrame it shouild not. I would reccomend using joints by the way.

Sooo Can you create it into a luna block instead of words? I have no idea what Im doing. The Primary part is just moving itself even though I used joints. Also if I unanchored everything in the model it will fall down. Im trying to put a model in the air and dont make it fall down.

The primary part is just moving itself, not the whole part inside the model. Also from Magus’s idea, it didnt work as well.

Ah yes the solution here is not changing the position but changing the cframe. If you were to change the cframe of the root part of a jointed assembly such as a humanoid you could tween or directly changed the cframe of the assembly by manipulated the cframe of the humanoidrootpart. This works for sure. So if you set up like this RootPart->ExampleTorso then ExampleTorso to everything else it would have to work. Otherwise you should share your code on what you exactly have written for this function. Because it would appear you are missing something.

Here is the code I have right now

-- >>: Variables
-- >>: Variables
local runService = game:GetService("RunService")

local model = script.Parent

-- >>: Main Code
local function Heartbeat(deltaTime)
	model.PrimaryPart.Orientation += Vector3.new(0, 10, 0) / deltaTime
end

runService.Heartbeat:Connect(Heartbeat)

It was used from somone else who tried to help me btw

If you need the entire model to rotate, you need to weld all of the other parts in the model to the PrimaryPart.

If your trying to rotate a model use :PivotTo:

local Model = workspace.Model
Model:PivotTo(Model:GetPivot() * CFrame.Angles(math.rad(number), math.rad(number), math.rad(number))
1 Like

i did it and it only affected the primarypart itself