How to lock rotation of a part?

I don’t want the part to rotate but it must be unachored, is it possible?

Nope, not that one. I want it not to rotate on every axis but it must be unanchored

If the part is unanchored,it’d fall.

But you can still rotate it.

In Unity, I can lock the rotation axis(X, Y, Z, or all). I’m wondering if this is possible in Roblox.

What do you mean by lock? Could you elaborate? On what axis you want it to rotate?

I mean when I lock an axis, the part will not be able to rotate on that axis. You can see it on Unity. Let me share an image.

2 Likes

You can use align orientation. Basically have a separate anchored part with your desired orientation (doesnt matter where, it can be far away from your part) with attachment on it. Add an attachment to your part too. Add allign orientation to the part you want to lock rotation on, and mark in it those two attachments.

Now your part will stay the same rotation. It will still be able to move, fall and do all other things, it just wont rotate

5 Likes

Alternatively, you cann add a script to your part with this

while true do

     task.wait()
     Script.Parent.Orientation.Y = 0

end

but this is not good for performance, because you are basically creating a neverending loop that repeats itself rapidly

There used to be things in roblox studio that resembled rigidbody of unity, one of such being the “Body Gyro”. But it got deprecated

1 Like

Screenshot (81)
So basically, when you put a tick in those box, it will freeze the rotation on that axis. For example, I freeze the Y axis, the part will not rotate on the Y axis.

1 Like

It would still rotate tho if u rotated it with a script (transform.Rotate()), just general physics wouldnt be able to rotate it

1 Like

Mark a solution if any of the answers helped

Prismatic constraint maybe? That could work.

Do NOT do this. Here is a better version of the script.

local part = script.Parent
local targetOrientation = Vector3.new(0, 0, 0) 
local currentOrientation  = part.Orientation

part.Changed:Connect(function(property) --wrote this on mobile so unfortunately no indentation.

if property == "Orientation" then

part.Orientation = Vector3.new(currentOrientation.X, targetOrientation.Y, currentOrientation.Z)

end

end)
8 Likes

I’m still trying to do it, I don’t really know what is happening. I tried the first time, it didn’t work. Then I did it again but in another place, it worked, and I did the same method that I have succeeded in my old place, it still didn’t work

The method suggested by @JustCallMeWay is actually better. Just make a server script with what he has written, and put it in your part

1 Like

It finally worked! Thank you so much!

1 Like

this is not Unity lol but i want that in roblox

Seriously, would be so helpful.

2 Likes

i couldnt agree more with you lol

2 Likes