Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you face a player towards the mouse in a server script?(FE)

Asked by 4 years ago

I cannot do it in a local script since there are other elements that depend on the way the player is facing in the server script. Right now I have a toggle on an ability that runs the following repeat loop: note that player, duration, playerRoot is defined outside the loop. getmouseposition is a remote function that returns the mouse position from a local script

stop = false
local start = tick()
repeat
    local mousep = getmouseposition:InvokeClient(player)
    playerRoot.CFrame = CFrame.new(playerRoot.Position, mousep)
    if tick() - start >= duration then
        --do something
        stop = true
until stop

By doing this, the movement is not as smooth because the loop runs slowly(Noticeable jitters) Is there a better way of doing this?

Answer this question