Why do the arms not reset? [SOLVED]

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want the arms to follow the mouse up and down when a tool is eqquiped

  2. What is the issue? Include screenshots / videos if possible!
    Everything is fine with the equipping the only issue is is that the arms dont reset to their
    original position and orientation

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    look on the internet and devforums

heres a picture on how it looks
image

heres the server side Script: (in ServerScriptService)

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ArmsEvent = ReplicatedStorage.Remotes.ArmsEvent
local ArmsEvent2 = ReplicatedStorage.Remotes.ArmsUnEvent

game.Players.PlayerAdded:Connect(function(player)
  player.CharacterAdded:Connect(function(character)
    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
			print(plr)
			print(position)
        mousePosition = position
      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)
	end)
		ArmsEvent2.OnServerEvent:Connect(function(plr)
			if plr == player then
				print(plr)
				end


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


			RenderService.Heartbeat:Connect(function()
				
				RightShoulder.C0 = CFrame.new(RightShoulder.C0.Position) * CFrame.Angles(1, 0.5, 0)
				--RightShoulder.C0 = CFrame.new(RightShoulder.C0.Orientation) * CFrame.Angles(0,90,0)

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

				local _, Y, Z = LeftShoulder.C0:ToEulerAnglesXYZ()
				LeftShoulder.C0 = CFrame.new(LeftShoulder.C0.Position) * CFrame.Angles(1, 0.5, 0)
				--LeftShoulder.C0 = CFrame.new(LeftShoulder.C0.Orientation) * CFrame.Angles(0,90,0)
			end)
		end)
  end)
end)

and the local side: (in the StarterPack)

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ArmsEvent = ReplicatedStorage.Remotes.ArmsEvent
local ArmsEvent2 = ReplicatedStorage.Remotes.ArmsUnEvent

mouse.Move:Connect(function()
	if player.Character:FindFirstChildWhichIsA("Tool") then
	if player.Character:FindFirstChildWhichIsA("Tool"):GetAttribute("ToolName") == "Weapon" then
print(player.Character:FindFirstChildWhichIsA("Tool"):GetAttribute("ToolName"))
  ArmsEvent:FireServer(mouse.Hit.p)
	end
	end
end)

player.Character.ChildRemoved:Connect(function(child)
	if child:IsA("Tool") then
		if child:GetAttribute("ToolName") == "Weapon" then
			ArmsEvent2:FireServer()
		end
	end
end)

i have no idea on why this is happening anything helps.

1 Like

Would setting RightShoulder.C0 to OldRightC0 in ArmsEvent2, not reset the arm?