Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago

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

Log in to vote
0
Answered by 2 years ago

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)

Ad

Answer this question