Hello,
So I made this arm rotation script that sends the rotation to the server then replicates to all clients. I thought this would fix the lagging issue, but apparently not.
Arm math script:
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local plr = Players.LocalPlayer
local char = plr.Character
local mouse = plr:GetMouse()
mouse.TargetFilter=workspace
game.ReplicatedStorage.ArmWeld:FireServer(true)
RunService.Heartbeat:Connect(function()
game:GetService("TweenService"):Create(char.HumanoidRootPart,TweenInfo.new(.3,Enum.EasingStyle.Quint),{CFrame = CFrame.new(char.HumanoidRootPart.CFrame.p, char.HumanoidRootPart.CFrame.p + Vector3.new(mouse.Hit.LookVector.x, 0, mouse.Hit.LookVector.z))}):Play()
local cframe = CFrame.new(char.RightUpperArm.RightElbowRigAttachment.WorldPosition+char.RightLowerArm.CFrame.UpVector*-(char.RightLowerArm.Position-char.RightLowerArm.RightElbowRigAttachment.WorldPosition).Magnitude, mouse.Hit.Position) * CFrame.Angles(math.pi/2, 0, 0)
game.ReplicatedStorage.ArmWeld:FireServer(false,cframe)
end)
Server script:
game.ReplicatedStorage.ArmWeld.OnServerEvent:Connect(function(p,e,r)
if e==true then
local char = p.Character
local armWeld1 = Instance.new("Weld")
armWeld1.Part0 = char.RightUpperArm
armWeld1.Part1 = char.RightLowerArm
armWeld1.Parent = char.RightLowerArm
armWeld1.Name="Armweld1"
else
local w = p.Character.RightLowerArm.Armweld1
game.ReplicatedStorage.ArmWeldClient:FireAllClients(w,r)
end
end)
Replicator Script:
armweldevent.OnClientEvent:Connect(function(w,r)
w.C0 = w.Parent.Parent.RightUpperArm.CFrame:toObjectSpace(r)
end)
- Br, iSyriux