Hello fellow devs, I am currently making a game that requires the car to rotate a certain way while in the air. when W is held, the car should face down, and when S is held, the car nose should point up, kind of like a plane. However, my method only works when the car faces a certain direction in the map. Instead, I would like it to work regardless of the direction the car is facing. This is my code I came up with:
function onKeyDown(inputObject, gameProcessedEvent) if carseat.Position.Y > 2.6 then if inputObject.KeyCode == Enum.KeyCode.W then turn.AngularVelocity = Vector3.new(0,0,2000000) end if inputObject.KeyCode == Enum.KeyCode.S then turn.AngularVelocity = Vector3.new(0,0,2000000) end end end function onKeyUp(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.W then turn.AngularVelocity = Vector3.new(0,0,0) end if inputObject.KeyCode == Enum.KeyCode.S then turn.AngularVelocity = Vector3.new(0,0,0) end end input.InputBegan:connect(onKeyDown) input.InputEnded:connect(onKeyUp)
It would be great if you can help me figure out how to solve this. Thanks in advance!!
turn.AngularVelocity = carnose.CFrame.lookVector * 2000000
rightVector is it's local X axis upVector is it's local Y Axis lookVector is it's local Z axis