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

How can you invert player controls?

Asked by 5 years ago

I cloned the ControlScript into StarterPlayerScripts and I changed the AddToPlayerMovement function to:

function MasterControl:AddToPlayerMovement(playerMoveVector)
    if ControlsInverted then
        playerMoveVector = -playerMoveVector
        moveValue = Vector3.new(moveValue.X + playerMoveVector.X, moveValue.Y + playerMoveVector.Y, moveValue.Z + playerMoveVector.Z)
    else
        moveValue = Vector3.new(moveValue.X + playerMoveVector.X, moveValue.Y + playerMoveVector.Y, moveValue.Z + playerMoveVector.Z)
    end
end

I added an InvertControls function:

function MasterControl:InvertControls(bool)
    ControlsInverted = bool
    print(bool)
end

and I added a ControlsInverted boolean: local ControlsInverted = false

----------

I was hoping this would just switch the controls immediately but it doesn't until someone starts pressing a different button, and just generally weird behavior, any ideas to improve this?

Answer this question