Is there any way to know which way a Part is facing?

So, I’m trying to make a drawer open when a player touches it, the problem is that I would like the drawer to ALWAYS open forward (even if I rotate it 90 degrees), I put a video showing how it looks when I rotate it to the side, see:

I would like it to always open to the front, but I don’t know how it would do this (I would like to do this in a way that I don’t have to worry about changing the drawer script anymore)

local CollectionService = game:GetService("CollectionService")
local TweenService = game:GetService("TweenService")

local Collectionbuttons = CollectionService:GetTagged("Buttons")
local Tweens = {
	Open = 0.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0;
	Close = 0.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0;	

for i,v in pairs(Collectionbuttons) do
		local TweenToPlay = TweenService:Create(v,,{CFrame = v.CFrame *,0,-4))})

Is there any way to do this?

Rotate the part.

I realize you may not be looking for this answer but this will make your life easier.


1 Like

I understood your idea a little, but can you explain it better?

I would like to do it in such a way that I would not have to worry about turning the piece over and over again

Just use lookvector:

1 Like

Just make sure your part’s front surface is in the correct direction.

For instance mine is in the correct direction

1 Like

Not sure if that is helpful. OP’s issue is that the part is going the “wrong way” because the part is not oriented correctly.

1 Like

If I’m not mistaken, the OP wants to tween the part forward with the forward facing part. Lookvector would be best suited for this.

He wants this to work on all drawers, regardless of orientation, lookvector does so accordingly based on the forward look of a part.

Another probable fix to this is:
Changing this:

local TweenToPlay = TweenService:Create(v,,{CFrame = v.CFrame *,0,-4))})

To this:

local TweenToPlay = TweenService:Create(v,,{CFrame = v.CFrame *,0,0))})
1 Like

I did some research, but I didn’t understand, can you explain?

All you need to do is make sure your part is rotating the right way. Could you post a screenshot of you selecting the FrontSurface property?

1 Like

You are linking it to a vector, which will always have the same effect, no matter on object orientation.

You could consider using :ToWorldSpace()


Sure, lets say you have a part that you want to push forward regardless of orientation, you’d want it to be done based on the parts actual orientation and work off of that or cframe which is both position and orientation.

Using this, we can take a part like this:

while true do
	script.Parent.CFrame = script.Parent.CFrame *, 0, -0.01)  -- change to fit direction (ROUGH EXAMPLE)

This accordingly sets the cframe with the cframe that suits towards it making it always based on orientation of part instead of world.

LookVector will also work in this case however it requires that the front of your part is actually the front.


Like3rdhoan123 said, change it to this:

for i,v in pairs(Collectionbuttons) do
local TweenToPlay = TweenService:Create(v,,{CFrame = v.CFrame * * 4)})

1 Like

Just make sure to rotate the part so that the Front surface is looking where the Left one currently is.

1 Like

what’s going to change ? What will change? Will it go the right way?

Yes because your code was depending on the rotation of it.

1 Like

Although @incapaz 's method is good for certain simple parts, it will not work at all for meshes that have different orientations:

Your best bet will be to use the cframe of the part and multiply with the cframe as you can have future changes for best customization rather then relying that front will always be front.

I’m testing Lookvector now, but I realized that “ToWorldSpace” is also a good bet

I’d rather recommend just multiplying with cframe, no need for lookvector or ToWorldSpace.

All you’re doing is multipying the parts cframe with another cframe. easy and simple and customizable.

script.Parent.CFrame = script.Parent.CFrame *,0,0) -- change the 0,0,0 to any values to any direction you like, if you want it moving forward based on forward lookvector, change last value.