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

Server sided arm movement does not work, any ideas?

Asked by
Nump4d 5
3 years ago

This script is in startercharacter scripts

local tweenService = game:GetService("TweenService")

local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer

local Character = Player.Character
local Root = Character:WaitForChild("HumanoidRootPart")
local RArm = Character:FindFirstChild("Right Shoulder", true)
local LArm = Character:FindFirstChild("Left Shoulder", true)
local YOffset = RArm.C0.Y
local YOffset2 = LArm.C0.Y

local CFNew, CFAng = CFrame.new, CFrame.Angles
local asin = math.asin

game:GetService("RunService").RenderStepped:Connect(function()
    local CameraDirection = Root.CFrame:toObjectSpace(Camera.CFrame).lookVector
    if RArm and LArm then
        if Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
            RArm.C0 = CFNew(0, YOffset, 0) * CFAng(0, -asin(CameraDirection.x), 0) * CFAng(asin(CameraDirection.y), 0, 0)
            LArm.C0 = CFNew(0, YOffset, 0) * CFAng(0, -asin(CameraDirection.x), 0) * CFAng(asin(CameraDirection.y), 0, 0)
        elseif Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
            RArm.C0 = CFNew(1, 0.5, 0) * CFAng(0,math.rad(90),0) * CFAng(0, 0, asin(CameraDirection.y))
            LArm.C0 = CFNew(-1, 0.5, 0) * CFAng(0,math.rad(-90),0) * CFAng(0, 0, -asin(CameraDirection.y))
        end
    end
end)

game.ReplicatedStorage.Look.OnClientEvent:Connect(function(otherPlayer, LArmCFrame, RArmCFrame)
    local RArm = otherPlayer.Character:FindFirstChild("Right Shoulder", true)
    local LArm = otherPlayer.Character:FindFirstChild("Left Shoulder", true)

    if RArm and LArm then
        tweenService:Create(RArm, TweenInfo.new(.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0), {C0 = RArmCFrame}):Play()
        tweenService:Create(LArm, TweenInfo.new(.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0), {C0 = LArmCFrame}):Play()
    end
end)

while wait(1) do
    game.ReplicatedStorage.Look:FireServer(RArm.C0)
    game.ReplicatedStorage.Look:FireServer(LArm.C0)
end

This script is in serverscriptservice, and there is a remote event called "Look" in replicatedstorage

game.ReplicatedStorage.Look.OnServerEvent:Connect(function(player, LArmCFrame, RArmCFrame)
    for key, value in pairs(game.Players:GetChildren()) do
        if value ~= player and (value.Character.LeftArm.Position - player.Character.LeftArm.Position).Magnitude < 50 then
            if value ~= player and (value.Character.RightArm.Position - player.Character.RightArm.Position).Magnitude < 50 then

                game.ReplicatedStorage.Look:FireClient(value, player, LArmCFrame, RArmCFrame)
            end
        end
    end
end)

2 answers

Log in to vote
0
Answered by 3 years ago

I don't know much about it but maybe the first script has to be local?

Ad
Log in to vote
0
Answered by 3 years ago

I don't know much about it but maybe the first script has to be local?

Answer this question