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

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
end

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

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

--etc...        

Is there a move efficient way of doing this?

Answer this question