npc enemy isn't assigned to any onscreen enemy, firstly. You probably want to cycle through all the onscreen enemies, and check against each one if it's a type that's a crab.
for(int i = 1; i <= Screen->NumNPCs(); i++)
{
npc enemy = Screen->LoadNPC(i);
if(enemy->Attributes[14] == 5)
{
enemy->Step=150;
}
}
The way you used Px is a bit odd since the enemy would move fast as soon as it moved left or right, and would stay that way forever and ever. If that's what you want then that's fine, but I would suggest checking if(enemy->Dir == DIR_LEFT || enemy->Dir == DIR_RIGHT) since it's more intuitive, and would work properly with multiple enemies on-screen.
Also, this only would happen for the very first frame that the script started, since it's not within a loop. On the other hand, this ought to work:
while(true)
{
for(int i = 1; i <= Screen->NumNPCs(); i++)
{
npc enemy = Screen->LoadNPC(i);
if(enemy->Attributes[15] == 5 && (enemy->Dir == DIR_LEFT || enemy->Dir == DIR_RIGHT))
{
enemy->Step=150;
}
}
Waitframe();
}
This would go in the void run() curly brackets. Also, this doesn't unset the enemy's speed when it's moving vertically. Doing that is possible, as it just requires a check for the enemy's direction to be up or down instead of left or right.