Serverside Arm Moving to mouse

Hello! I have made a system where the player moves their mouse, and their right arm follows, this is in R6. It is working fine so far except I want it to happen on the server as well.

Here is the code:

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local plr = Players.LocalPlayer
local char = plr.Character
local mouse = plr:GetMouse()

local armOffset = char.Torso.CFrame:Inverse() * char["Right Arm"].CFrame

local armWeld = Instance.new("Weld")
armWeld.Part0 = char.Torso
armWeld.Part1 = char["Right Arm"]
armWeld.Parent = char

RunService.Heartbeat:Connect(function()
	local cframe = CFrame.new(char.Torso.Position, mouse.Hit.Position) * CFrame.Angles(math.pi/2, 0, 0)
	armWeld.C0 = armOffset * char.Torso.CFrame:toObjectSpace(cframe)
	--game.ReplicatedStorage.ArmMovement:FireServer(cframe, mouse.Hit)
end)

As you can see I tried firing a remote event, but that did not work.

In the script that picked up the event, I tried repeating the whole process but it simply wouldn’t work.

Can anyone help? Thank you and happy holidays.

Can we see your ServerScript?
Also, keep in mind that in a LocalScript, it’s best practice to wait for things to load.

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local plr = Players.LocalPlayer
repeat task.wait() until plr.Character
local char = plr.Character
local mouse = plr:GetMouse()

char:WaitForChild("Torso") 
char:WaitForChild("Right Arm")
local armOffset = char.Torso.CFrame:Inverse() * char["Right Arm"].CFrame
...
game.ReplicatedStorage.ArmMovement.OnServerEvent:Connect(function(plr, cframe, arm)
	
end)

It is just connecting the event as of now, it used to be the same thing as the local script, which didn’t move the arm on the server.

I now changed it to this :

Server:

game.ReplicatedStorage.ArmMovement.OnServerEvent:Connect(function(plr, cframe, arm, mouse)
	local char = plr.Character
	local cframe2 = CFrame.new(char.Torso.Position, mouse.Position) * CFrame.Angles(math.pi/2, 0, 0)

	local armOffset = char.Torso.CFrame:Inverse() * char["Right Arm"].CFrame

	local armWeld = Instance.new("Weld")
	armWeld.Part0 = char.Torso
	armWeld.Part1 = char["Right Arm"]
	armWeld.Parent = char

	armWeld.C0 = armOffset * char.Torso.CFrame:toObjectSpace(cframe)
end)

Local:

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local plr = Players.LocalPlayer
local char = plr.Character
local mouse = plr:GetMouse()

local armOffset = char.Torso.CFrame:Inverse() * char["Right Arm"].CFrame

local armWeld = Instance.new("Weld")
armWeld.Part0 = char.Torso
armWeld.Part1 = char["Right Arm"]
armWeld.Parent = char

RunService.Heartbeat:Connect(function()
	local cframe = CFrame.new(char.Torso.Position, mouse.Hit.Position) * CFrame.Angles(math.pi/2, 0, 0)
	armWeld.C0 = armOffset * char.Torso.CFrame:toObjectSpace(cframe)
	game.ReplicatedStorage.ArmMovement:FireServer(cframe, armWeld.C0, mouse.Hit)
end)

The arm flies away when tested with 2 people, I don’t know why.

CFrame.new(char.Torso.Position, mouse.Hit.Position)

Probably because you’re using the mouse’s current location when constructing a CFrame for the arm weld.

So how could I fix that? I want the arm to follow the mouse

I put in that code of mouse.Hit.Position and it just did nothing when tested on the server.