My issue: I have this code where it uses a body angular velocity to rotate this hoverboard. After the user stops holding A or D and wants to move forward it just moves in one direction not the turned direction is there a way to make this work?
Part of the code that does rotation and moving:
KeyHeld = false
function onKeyPress(inputObject,gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.A then
KeyHeld = true
if KeyHeld == true then
angularvelo.AngularVelocity = Vector3.new(0,2,0)
wait()
end
end
end
function onKeyRelease(inputObject,gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.A then
KeyHeld = false
angularvelo.AngularVelocity = Vector3.new(0,0,0)
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)
game:GetService("UserInputService").InputEnded:connect(onKeyRelease)
KeyHeld2 = false
function onKeyPress(inputObject,gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.D then
KeyHeld2 = true
if KeyHeld2 == true then
angularvelo.AngularVelocity = Vector3.new(0,-2,0)
wait()
end
end
end
function onKeyRelease(inputObject,gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.D then
KeyHeld2 = false
angularvelo.AngularVelocity = Vector3.new(0,0,0)
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)
game:GetService("UserInputService").InputEnded:connect(onKeyRelease)
KeyHeld3 = false
function onKeyPress(inputObject,gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.W then
KeyHeld3 = true
if KeyHeld3 == true then
bodyvelo.Velocity = Vector3.new(-15,0,0)
wait()
end
end
end
function onKeyRelease(inputObject,gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.W then
KeyHeld3 = false
bodyvelo.Velocity = Vector3.new(0,0,0)
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)
game:GetService("UserInputService").InputEnded:connect(onKeyRelease)
