Two built-in variables for handling the mouse's x and y location.
var mouse_x = 0;
var mouse_y = 0;
A function that retrieves the mouse_x and mouse_y location and then changes the image based on that angle.
angle = mouse_direction(mouse_x, mouse_y)
Instead of having people making their own ways of doing this, which will probably hurt the server some how depending on how it's coded, this should be incorporated in the language as a built-in tool developers can use.