How do I make something happen on the server but not the client

So, I’m making a shooter, and I want the arms to follow the mouse position. So, I found a script that does that, but it doesn’t work well with my current script.

scripts:
client (happens every step):

character["Right Arm"].LocalTransparencyModifier = character["Right Arm"].Transparency
	character["Left Arm"].LocalTransparencyModifier = character["Left Arm"].Transparency
	local camCF = camera.CoordinateFrame
	local distance = (character.Head.Position - camCF.p).magnitude
	if distance <= 2 and humanoid.Health ~= 0 then
		rightShoulder.C0 = rightShoulder.C0:lerp((camCF * CFrame.new(1, -1, 0)):toObjectSpace(torso.CFrame):inverse() * CFrame.Angles(0, math.pi/2, 0), updateSpeed)
		leftShoulder.C0 = leftShoulder.C0:lerp((camCF * CFrame.new(-1, -1, 0)):toObjectSpace(torso.CFrame):inverse() * CFrame.Angles(0, -math.pi/2, 0), updateSpeed)
	else
		rightShoulder.C0 = CFrame.new(1, 0.5, 0) * CFrame.Angles(0, math.pi/2, 0)
		leftShoulder.C0 = CFrame.new(-1, 0.5, 0) * CFrame.Angles(0, -math.pi/2, 0)
	end

server happens when the player’s mouse moves:

 local RenderService = game:GetService("RunService")
    local ToolMotor = Instance.new("Motor6D")
    ToolMotor.Parent = character:WaitForChild("HumanoidRootPart")
    local mousePosition = Vector3.new(0, 0, 0)

    ArmsEvent.OnServerEvent:Connect(function(plr, position)
      if plr == player then
        mousePosition = position
      end
    end)

    local RightShoulder, LeftShoulder, ToolGrip = character.Torso:WaitForChild("Right Shoulder"), character.Torso:WaitForChild("Left Shoulder"), ToolMotor

    RenderService.Heartbeat:Connect(function()
      local X = -(math.asin((character.HumanoidRootPart.Position - mousePosition).unit.y))

      local _, Y, Z = RightShoulder.C0:ToEulerAnglesXYZ()
      local OldRightC0 = RightShoulder.C0
      RightShoulder.C0 = CFrame.new(RightShoulder.C0.Position) * CFrame.Angles(X, Y, Z)
      local Difference = OldRightC0.Position - RightShoulder.C0.Position

      local _, Y, Z = ToolGrip.C0:ToEulerAnglesXYZ()
      ToolGrip.C0 = CFrame.new(ToolGrip.C0.Position) * CFrame.Angles(X, Y, Z)

      local _, Y, Z = LeftShoulder.C0:ToEulerAnglesXYZ()
      LeftShoulder.C0 = CFrame.new(LeftShoulder.C0.Position) * CFrame.Angles(X, Y, Z)
    end)
1 Like

Can you send A video if possible?


mainly the stuttering. the two scripts are trying to change the arms at the same time

Right, you have two scripts trying to do the same thing.

So pick one.

no let me explain the server side one looks weird on the client side, like very weird. while the client one looks good on the client but bad on the server

delete the stuff the server does on the client but then replace it in the client with the same thing