Need help with a conditional statement checking a part's orientation

Hello. I’m trying to make a working door that checks if it is at a certain orientation and progress. But it errored. Could you guys help me?

Here’s my code:

local door = script.Parent
local doorHandle = door.DoorHandle
local clickHandle = doorHandle.ClickHandle

local function onClicked()
	if door.InnerDoor.Orientation == door.InnerDoor(0, 90, 0) then
		print("Should return")
	else
		print("Should rotate 15 degrees and move.")
	end
end

game.Workspace.Door.DoorHandle.ClickHandle.MouseClick:Connect(onClicked)

Thanks!

1 Like

Could you send a screenshot of the error so that I can better understand what the issue is?

1 Like

Here!

Your issue is probably that you are attempting to compare a InnerDoor’s orientation to a value that is not a member of InnerDoor. In this case, you should use a Vector3 value to compare to InnerDoor’s orientation.

local door = script.Parent
local doorHandle = door.DoorHandle
local clickHandle = doorHandle.ClickHandle

local function onClicked()
	if door.InnerDoor.Orientation == Vector3.new(0, 90, 0) then
		print("Should return")
	else
		print("Should rotate 15 degrees and move.")
	end
end

game.Workspace.Door.DoorHandle.ClickHandle.MouseClick:Connect(onClicked)
1 Like

Ohhhh thank you! I forgot that Orientation is a Vector3.

Quick question. Is position also a Vector3?

Yes. Position as well as size are Vector3 values.