Model Not Rotating

As a little side project, I’ve been trying to make a rotating circle of parts, to get back into coding (As it’s been a while)

However, I’ve run into a problem. Whenever I try to rotate the model, it doesn’t rotate. Instead, it rotates the hitbox?

I don’t think I’m doing anything wrong, as I am using the primary part, but It’s still not moving.

local CircleCenter = game.Workspace.Circle.CenterPart

wait(3)

while true do
	
	CircleCenter.Orientation += Vector3.new(0,0,10)
	
	wait()

What am I doing wrong? How do I get it to rotate? Any help is greatly appreciated. :smile:

1 Like

Make sure all of the parts are welded to the hitbox.

How do I do that? I’ve never really done welding before.

Add weld constraints into the circle (same amount as the parts), set their Part0 as the Center, and go through the other parts and one by one set the Part1 of a weld constraint to that part. If it helps you at all, here is the Roblox reference for it.

Well, the problem here is that the parts used to make the circle were cloned. Would I still be able to add welds?

Yes, you would still be able to weld them. If you did it in a script, just make the weld within the script. Also, make sure that the weld is a WeldConstraint and not a Weld.

Alright, I’m back from trying it, and it still only moves the hitbox. Even when I use CFrame, it does the same thing.

Try unanchoring the other parts and leave the hitbox anchored.

orientation stops at 180 i think, you will have to use cframe (ill provide a example in a sec)

also use task.wait(), wait() should be deprecated, but its so widely used it isn’t, task.wait() supersedes it because it is more optimized

while task.wait() do
    script.Parent.CFrame *= CFrame.fromEulerAnglesXYZ(0.1,0,0)
end

edit: wait IS deprecated, do not use it

1 Like

i think if you set the PrimaryPart of the model to the centerpart and use game.Workspace.Circle.PrimaryPart

then change the orientation of that
also you should move wait() to the start of the loop

one more thing; you should use tweens for something like this

remember to tween infinitely, not use a while loop, that can cause some really bad optimization, to tween infinite make the delay time in tweeninfo (4th parameter) -1

and again, dont use wait()

How would I leave the hitbox anchored?

Once again, it only spun the hitbox (Or the selection thing, It’s not really a hitbox)

You’d probably want to use the Model’s :PivotTo() function instead of changing its PrimaryPart’s orientation. Try this:

local Circle = game.Workspace.Circle

while true do
    Circle:PivotTo(Circle:GetPivot() * CFrame.Angles(0,0,math.rad(10)))
    task.wait()
end

The reason this works is that setting a PrimaryPart’s properties only affect it, not the whole model.

1 Like

That didn’t change anything. And I was going to use tweens, but I needed this to work first.

This… actually worked. Could you explain how this works though? I like to get a understanding of things, as I feel like I should know what I code.

i thought pivots weren’t usable in runtime?

Sure! Sorry if I didn’t explain enough.

local Circle = game.Workspace.Circle

while true do
    Circle:PivotTo(Circle:GetPivot() * CFrame.Angles(0,0,math.rad(10)))
    task.wait()
end

Let’s break the big part down.

Circle:PivotTo()

PivotTo is essentially the new SetPrimaryPartCFrame (except you don’t need a PrimaryPart, everything has a pivot), so if you’ve ever used that then you know (but if you don’t, it basically moves everything in the model relative to the PrimaryPart, and sets the PrimaryPart’s CFrame to the CFrame you give it)

Circle:GetPivot()

GetPivot is basically GetPrimaryPartCFrame, but you don’t need a PrimaryPart. It just gives you the CFrame of the Pivot.

CFrame.Angles(0,0,math.rad(10))

CFrame.Angles gives you a CFrame with the specified rotation. It’s taken in radians though, so you have to use math.rad() to convert degrees to radians.

After all that, you multiply them together (which is essentially addition in this scenario) and it gives you a new CFrame that is rotated 10 degrees on the Z-axis compared to the original CFrame. After all that, you set the model’s Pivot to the CFrame you just computed.

Hopefully this was clear enough!

So basically, Pivot is kind of like Using PrimaryPart, but without PrimaryPart.

I’m interested, though. Could you still use tweening with this, or would you have to find another method?

Tweening would work, but you’d have to tween the PrimaryPart and weld everything else to it.

If you do that, you might as well use a constraint (like a HingeConstraint)