Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I be able to find the orientation of a part?

I'm working on a controllable, flying object, and with the way I'm making it, I need to find the orientation so I could find which way the object should move.

KeyDownEvent.OnServerEvent:Connect(function(player,key)
if player.Character.Humanoid.Sit == true and script.Parent.Parent.Seat.Occupant.Parent.Name == player.Name then
	
	
	if key == "w" then
		if script.Parent.Orientation == Vector3.new(0,-45,180) or Vector3.new(0,-90,180) then
			print(script.Parent.Orientation)
			print("woohooo!")
		end
		
		
		
		
	end
end

end)

And for some reason, on Line 7 and Line 8, it stills prints the Orientation of the part, and "woohooo!". So if you know what is causing it and how to fix it, you are more than welcome to help me out!

1 answer

Woohooo! After some fiddling around, I got it working by adding a variable of the position/rotation, then matching it with the orientation of the part!

local test = Vector3.new(0,-45,180)

--w

KeyDownEvent.OnServerEvent:Connect(function(player,key) if player.Character.Humanoid.Sit == true and script.Parent.Parent.Seat.Occupant.Parent.Name == player.Name then

	if key == "w" then
		if script.Parent.Orientation == test then
			print(script.Parent.Orientation)
			print("woohooo!")
		end
		
		
		
		
	end
end

end)

(the variable i added was in the Line 1)

This discussion is preserved as it was. New answers, comments, and votes are closed.