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

How to make this smoother? Filtering enabled.

Asked by
aiuis 85
6 years ago
Edited 6 years ago

Made these scripts for player's arms to follow player's cursor's Y angle. However, when sending mouse's position from client to server and then applying it to player's Motor6Ds makes it very choppy. I think I should use CFrame:lerp, and I tried but I still couldn't manage to make it work.

Local script:

local player=game.Players.LocalPlayer
local mouse=player:GetMouse()

mouse.Move:Connect(function()
    local argument=CFrame.Angles(math.asin((mouse.Hit.p-mouse.Origin.p).unit.y),0,0)
    game.ReplicatedStorage.RemoteEvent:FireServer('Arms',argument)
end)

Server script:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player,variant,argument)
    if argument=='Arms'then
        player.Character.RightLowerArm.RightElbow.C0=CFrame.new(0,-.2,0)*argument
        player.Character.LeftLowerArm.LeftElbow.C0=CFrame.new(0,-.2,0)*argument
    end
end)

Thank you for your time.

1
Why not do it on the client instantly, and then replicate it to the rest of the clients? framed 1 — 6y
0
Thank you for putting me on the right way. I got it to work perfectly! <3 aiuis 85 — 6y

Answer this question