Replicate Arm Movement to server

local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

local char = Player.Character or Player.CharacterAdded:Wait()
local Root = char:WaitForChild("HumanoidRootPart")
local RunService = game:GetService("RunService")

local CN,CA = CFrame.new,CFrame.Angles
local an = math.asin

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


local armWeld = char:FindFirstChild("Right Shoulder",true)

RunService.Heartbeat:Connect(function()
	if char:FindFirstChild("Torso") then
		local offset = CN(0,0,-0.5)*CA(0,math.rad(90),0)
		local cframe = CN(char.Torso.Position, Mouse.Hit.Position) * CA(math.pi/2, 0, 0)*offset
		local cf = armOffset * char.Torso.CFrame:toObjectSpace(cframe) * CN(0,0,-0.5)
		armWeld.C0 = cf
	end
end)

I want to replicate the script above to server

1 Like