get rid of your else statements.
Have it so it's like this
PHP Code:
if (keydown(0)){
}
else if (keydown(2)){
}
if (keydown(1)){
}
else if (keydown(3)){
}
I'd also suggest use vecx and y to make your script shorter
PHP Code:
for (temp.i=0;i<4;i++){
if (keydown(i)){
player.x += vecx(i)*client.playerSpeed;
player.y += vecy(i)*client.playerSpeed;
}
}
I've intentionally left out the onwall detection for you to do btw so you can understand the concept. Have fun.