Here:
addEventHandler( "onClientCursorMove", getRootElement( ),
function ( cursorX, cursorY, absoluteX, absoluteY, x,y,z)
local pedday = getLocalPlayer()
if (getElementVelocity(pedday) <= 0) then
local x1,y1,_ = getElementPosition(pedday)
local r = findRotation(x1,y1,x,y)
setElementRotation(pedday, 0, 0, r)
curX, curY, curZ = getElementRotation(pedday)
setPedLookAt(pedday, x, curX , curY, z, -3000)
end
end)
function findRotation(x1,y1,x2,y2)
local t = -math.deg(math.atan2(x2-x1,y2-y1))
if t < 0 then t = t + 360 end;
return t;
end
When I move my mouse it rotates the player acording to where I look at.