hello devs, i making my own melee system with moving arms.
but i have one issue with “visible client position arms on server”.
here u can see what i mean:
Client:
local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local tweenService = game:GetService("TweenService")
local char = Player.Character
local origRightS = char:WaitForChild("Torso"):WaitForChild("Right Shoulder").C0
local origLeftS = char:WaitForChild("Torso"):WaitForChild("Left Shoulder").C0
local origNeck = char:WaitForChild("Torso"):WaitForChild("Neck").C0
local m = Player:GetMouse()
local UIS = game:GetService("UserInputService")
local IsEquipped = false
--Changes the player's arm and head position to your mouse
game:GetService("RunService").RenderStepped:Connect(function()
if IsEquipped == true then
if char.Torso:FindFirstChild("Right Shoulder") then
char.Torso["Right Shoulder"].C0 = char.Torso["Right Shoulder"].C0:Lerp(CFrame.new(1, .65, 0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y), 1.55, 0, 0) , 0.1)
end
if char.Torso:FindFirstChild("Left Shoulder") then
char.Torso["Left Shoulder"].C0 = char.Torso["Left Shoulder"].C0:Lerp(CFrame.new(-1, .65, 0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y), -1.55, 0, 0) , 0.1)
end
if char.Torso:FindFirstChild("Neck") then
char.Torso["Neck"].C0 = char.Torso["Neck"].C0:Lerp(CFrame.new(0, 1, 0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y) + 1.55, 3.15, 0), 0.2)
end
else
if char.Torso:FindFirstChild("Right Shoulder") then
char.Torso["Right Shoulder"].C0 = char.Torso["Right Shoulder"].C0:lerp(origRightS, 0.1)
end
if char.Torso:FindFirstChild("Left Shoulder") then
char.Torso["Left Shoulder"].C0 = char.Torso["Left Shoulder"].C0:lerp(origLeftS, 0.1)
end
if char.Torso:FindFirstChild("Neck") then
char.Torso["Neck"].C0 = char.Torso["Neck"].C0:lerp(origNeck, 0.1)
end
end
end)
--Enables if tool is equipped (If you want a specific tool to not move arm, add a value in the tool called HoldArmsStill)
char.ChildAdded:Connect(function()
for i,v in pairs(char:GetChildren()) do
if v:IsA("Tool") then
IsEquipped = true
end
end
end)
char.ChildRemoved:Connect(function(child)
if child:IsA("Tool") then
IsEquipped = false
end
end)
--Recives remote event fired by other players.
game.ReplicatedStorage.ArmsEvent.OnClientEvent:Connect(function(PlrAgain, neckCFrame, RsCFrame, LsCFrame)
local Neck = PlrAgain.Character.Torso:FindFirstChild("Neck", true)
local Rs = PlrAgain.Character.Torso:FindFirstChild("Right Shoulder", true)
local Ls = PlrAgain.Character.Torso:FindFirstChild("Left Shoulder", true)
if Neck then
tweenService:Create(Neck, TweenInfo.new(.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0), {C0 = neckCFrame}):Play()
end
if Rs then
tweenService:Create(Rs, TweenInfo.new(.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0), {C0 = RsCFrame}):Play()
end
if Ls then
tweenService:Create(Ls, TweenInfo.new(.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0), {C0 = LsCFrame}):Play()
end
end)
--Fires the remote event for arms and head's CFrame.
game["Run Service"].RenderStepped:Connect(function()-- you can change here if you want
game.ReplicatedStorage.ArmsEvent:FireServer(char.Torso["Neck"].C0, char.Torso["Right Shoulder"].C0, char.Torso["Left Shoulder"].C0)
end)
Server:
game.ReplicatedStorage.ArmsEvent.OnServerEvent:Connect(function(player, neckCFrame, RsCFrame, LsCFrame)
for key, value in pairs(game.Players:GetChildren()) do
if value ~= player and (value.Character.Head.Position - player.Character.Head.Position).Magnitude < 70 then--you will see player's movement depending on the range/magnitude(bigger the number the larger range)
game.ReplicatedStorage.ArmsEvent:FireClient(value, player, neckCFrame, RsCFrame, LsCFrame)
end
end
end)
I know this was done to display the local positions of all players. But how can I make this visible to the server itself?