Hello, I am making a weapons system and I want everyone to see the arm movements. I’m sending it from the client to server then to all other clients. The issue is the one arm breaks and I cannot fix it.
Client
local RootPos = Root.Position
local TorsoPos = Torso.Position
local MousePos = Mouse.Hit.Position
Root.CFrame = CFrame.new(RootPos, Vector3.new(MousePos.X, RootPos.Y, MousePos.Z))
local rightX, rightY, rightZ = RightShoulder.C0:ToEulerAnglesYXZ()
RightShoulder.C0 = (RightShoulder.C0 * CFrame.Angles(0, 0, -rightZ)) * CFrame.Angles(0, 0, math.asin((Mouse.Hit.p - Mouse.Origin.p).unit.y))
local leftX, leftY, leftZ = LeftShoulder.C0:ToEulerAnglesYXZ()
LeftShoulder.C0 = (LeftShoulder.C0 * CFrame.Angles(0, 0, -leftZ)) * CFrame.Angles(0, 0, math.asin((-Mouse.Hit.p - -Mouse.Origin.p).unit.y))
local DataToSend = {
["RightData"] = {rightZ, -Mouse.Hit.p - -Mouse.Origin.p};
["LeftData"] = {leftZ, -Mouse.Hit.p - -Mouse.Origin.p};
}
RepMoveEvent:FireServer("Arms", DataToSend)
Server
RepMoveEvent.OnServerEvent:Connect(function(plr, MovTY, data)
if MovTY == "Lean" then
RepMoveEvent:FireAllClients(plr.Name, "Lean", data)
elseif MovTY == "Arms" then
RepMoveEvent:FireAllClients(plr.Name, "Arms", data)
end
end)
Replication Client
RepMoveEvent.OnClientEvent:Connect(function(plr, MovTY, data)
if plr == game.Players.LocalPlayer.Name then
return
end
if MovTY == "Lean" then
--RepMoveEvent:FireAllClients(plr.Name, "Lean", data)
elseif MovTY == "Arms" then
print(data)
local character = game.Players[plr].Character
if character and character:FindFirstChild("Torso")then
local Root = character:WaitForChild("HumanoidRootPart")
local Torso = character:WaitForChild("Torso")
local RightShoulder = Torso:WaitForChild("Right Shoulder")
local LeftShoulder = Torso:WaitForChild("Left Shoulder")
local LeftData = data.LeftData
local RightData = data.RightData
RightShoulder.C0 = (RightShoulder.C0 * CFrame.Angles(0, 0, -RightData[1])) * CFrame.Angles(0, 0, math.asin((RightData[2]).unit.y))
LeftShoulder.C0 = (LeftShoulder.C0 * CFrame.Angles(0, 0, -LeftData[1])) * CFrame.Angles(0, 0, math.asin((LeftData[2]).unit.y))
else
print("Cannot Find Player Not Replicating")
return
end
end
end)