So, I’m trying to make the arm follow the mouse, It’s functional but has a slight problem that I can’t figure out. I have edited this script to work with the right arm but the problem is when I go close to a part, the arm slightly goes up. I’m unsure how to resolve this problem, what seems the cause of the problem? And how do I fix it?
Here is the link of the script I used:
Glad you ask here is another script this one moves with your mouse:
local plr = game.Players.LocalPlayer
repeat wait(.1) until plr.Character
local character = plr.Character
local torso = character:WaitForChild("Torso")
local rightarm = character:WaitForChild("Right Arm")
local leftarm = character:WaitForChild("Left Arm")
local leftshoulder = torso:WaitForChild("Left Shoulder")
local rightshoulder = torso:WaitForChild("Right Shoulder")
local camera = game:GetService("Workspace").CurrentCamera
game:GetService("RunService").RenderStepped:Connect(function()
if leftshoulder and leftarm then
leftshoulder.C0 = CFrame.new(-1, 0.5, -0.2) * CFrame.Angles(math.rad(70) + math.asin((Mouse.Hit.p - Mouse.Origin.p).unit.y), math.rad(-90), math.rad(52))
end
if rightshoulder and rightarm then
rightshoulder.C0 = CFrame.new(1, 0.5, -0.2) * CFrame.Angles(math.rad(120) + math.asin((Mouse.Hit.p - Mouse.Origin.p).unit.y), math.rad(90), math.rad(-104))
end
end)
thats what i found weird i tried fixing but no luck But i have found something that can help you its a roblox file that has the arm move with mouse thing script here its the same script but this one is working way better :armMovement.rbxl (23.4 KB)
yea you can you basically get the position of the hand in the client then put that position of the hand it in the server then on the server you fire it to all the client which is a best approach here is the script
local script for arm:
local plr = game.Players.LocalPlayer
repeat wait(.1) until plr.Character
local character = plr.Character
local torso = character:WaitForChild("Torso")
local rightarm = character:WaitForChild("Right Arm")
local leftarm = character:WaitForChild("Left Arm")
local leftshoulder = torso:WaitForChild("Left Shoulder")
local rightshoulder = torso:WaitForChild("Right Shoulder")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UpgradePosEvent = ReplicatedStorage:WaitForChild("upgradepos") ---your remote event
local camera = game:GetService("Workspace").CurrentCamera
local Mouse = plr:GetMouse()
game:GetService("RunService").RenderStepped:Connect(function()
if leftshoulder and leftarm then
leftshoulder.C0 = CFrame.new(-1, 0.5, -0.2) * CFrame.Angles(math.rad(70) + math.asin((Mouse.Hit.p - Mouse.Origin.p).unit.y), math.rad(-90), math.rad(52))
end
if rightshoulder and rightarm then
rightshoulder.C0 = CFrame.new(1, 0.5, -0.2) * CFrame.Angles(math.rad(120) + math.asin((Mouse.Hit.p - Mouse.Origin.p).unit.y), math.rad(90), math.rad(-104))
end
end)
while true do
if rightshoulder and rightarm then
UpgradePosEvent:FireServer(rightshoulder,rightshoulder.C0)
end
if leftshoulder and leftarm then
UpgradePosEvent:FireServer(leftshoulder,leftshoulder.C0)
end
wait(.35)
end
another local script put it in StarterPlayerscript:
local plr = game.Players.LocalPlayer
UpgradePosEvent.OnClientEvent:Connect(function(thing, thing2, plaer)
if thing and thing2 and plaer ~= plr then
thing.C0 = thing2
end
end)
Server script put in server script service:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UpgradePosEvent = ReplicatedStorage:WaitForChild("upgradepos")
UpgradePosEvent.OnServerEvent:Connect(function(plr, thing, thingC0)
if plr and plr.Character and thing and thing.Parent and thing.Parent.Parent == plr.Character and thingC0 and thing:IsA("Motor6D") then
UpgradePosEvent:FireAllClients(thing, thingC0, plr)
end
end)
well you can add something like this
that mean you add a variable then on the renderstep function you get to see if the variable is true then start changing position. i havnt been active on the script so i may forgot how i did the moving arm stuff
local toolEquip = false ---a variable to know if the tool is equiped
tool.Equipped:Connect(function()
toolEquip = true ---the tool is equiped so we make the variable to true
end
tool.Unequipped:Connect(function()
toolEquip = false ---the tool is Unequiped so we make the variable to false
end
game:GetService("RunService").RenderStepped:Connect(function()
if toolEquip == false then return end ----if the variable is false that mean the tool isnt equiped so we wont execute the script till the variable becomes true
if leftshoulder and leftarm then
leftshoulder.C0 = CFrame.new(-1, 0.5, -0.2) * CFrame.Angles(math.rad(70) + math.asin((Mouse.Hit.p - Mouse.Origin.p).unit.y), math.rad(-90), math.rad(52))
end
if rightshoulder and rightarm then
rightshoulder.C0 = CFrame.new(1, 0.5, -0.2) * CFrame.Angles(math.rad(120) + math.asin((Mouse.Hit.p - Mouse.Origin.p).unit.y), math.rad(90), math.rad(-104))
end
end)
while true do
if toolEquip == false then return end ---same here
if rightshoulder and rightarm then
UpgradePosEvent:FireServer(rightshoulder,rightshoulder.C0)
end
if leftshoulder and leftarm then
UpgradePosEvent:FireServer(leftshoulder,leftshoulder.C0)
end
wait(.35)
end
Would you mind to share how you did that? I’ve been looking on how to make it so that your arms follow your mouse only when you equip a tool for a while now.
we move the arms on client and we replicated that moves on ServerSide and on Client again.
*Local script*
local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer
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
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)
char.ChildAdded:Connect(function()
for i,v in pairs(char:GetChildren()) do
if v:IsA("Tool") then
if v:FindFirstChild("HoldArmsStill") then
else
IsEquipped = true
end
end
end
end)
game.ReplicatedStorage.Look.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
Neck.C0 = neckCFrame
end
if Rs then
Rs.C0 = RsCFrame
end
if Ls then
Ls.C0 = LsCFrame
end
end)
while wait(2) do -- you can change here if you want
game.ReplicatedStorage.Look:FireServer(char.Torso["Neck"].C0, char.Torso["Right Shoulder"].C0, char.Torso["Left Shoulder"].C0)
end
*ServerSide*
game.ReplicatedStorage.Look.OnServerEvent:Connect(function(player, neckCFrame, RsCFrame, LsCFrame)
for key, value in pairs(game.Players:GetChildren()) do
if value ~= player then
game.ReplicatedStorage.Look:FireClient(value, player, neckCFrame, RsCFrame, LsCFrame)
end
end
end)