Still have questions? Join our Discord server and get real time help.
Log in to vote

More efficient way to script directional controls?

Asked by 9 days ago
Edited 9 days ago

I have the player as a ball, and I'm currently scripting the controls. When a WASD key is held the velocity is changed so that the ball moves correspondingly. I currently have multiple while-statements that run when a single key is held, or when a combination of keys are held(WA, SD)


while UIS:IsKeyDown(Enum.KeyCode.W) do
    --roll forward

while UIS:IsKeyDown(Enum.KeyCode.D) do
    -- roll to the right

while UIS:IsKeyDown(Enum.KeyCode.A) and  UIS:IsKeyDown(Enum.KeyCode.W) do
    --move diagonally


Is there a move efficient way of doing this?

Answer this question