I'm making a gun, and decided to add animations and make the player's arms follow the mouse. I have a problem and a question.
Firstly, I'm having a weird problem, I have the gun, but when I duplicate it, the second one's "follow camera" system doesn't work.. Here's the code
local plr = game.Players.LocalPlayer
repeat wait() until game.Players.LocalPlayer.Character
local char1 = plr.Character
local Anim = char1.Humanoid:LoadAnimation(script.Parent.Idle)
local RightArm = char1.Torso["Right Shoulder"].C0
local LeftArm = char1.Torso["Left Shoulder"].C0
local Neck = char1.Torso["Neck"].C0
local ChangeVariable = false
repeat wait() until game.Players.LocalPlayer.Character
local char = plr.Character
local m = plr:GetMouse()
game["Run Service"].RenderStepped:Connect(function()
if script.Parent.BoolEquipped.Value == true then
local c = game.Workspace.CurrentCamera
char.Torso["Right Shoulder"].C0 = CFrame.new(1,0.5,0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y),1.55,0)
char.Torso["Left Shoulder"].C0 = CFrame.new(-1,0.5,0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y),-1.55,0)
char.Torso["Neck"].C0 = CFrame.new(0,1,0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y) + 1.55,3.15,0)
else
local c = game.Workspace.CurrentCamera
char.Torso["Right Shoulder"].C0 = RightArm
char.Torso["Left Shoulder"].C0 = LeftArm
char.Torso["Neck"].C0 = Neck
end
end)
script.Parent.Unequipped:Connect(function()
char.Torso["Right Shoulder"].C0 = CFrame.new(0,0,0)
char.Torso["Left Shoulder"].C0 = CFrame.new(0,0,0)
char.Torso["Neck"].C0 = CFrame.new(0,0,0)
end)
script.Parent.Equipped:Connect(function()
Anim:Play()
end)
script.Parent.Unequipped:Connect(function()
Anim:Stop()
end)
I also have a question, does anyone know how can I make it so that the character's arms follow the mouse, but in a server script?

7 comments
Use a remote event to fire from server to client, cuz there is no way to make arms move with a server script, as you cannot get the local player
and i dont get wht u mean by: Firstly, I'm having a weird problem, I have the gun, but when I duplicate it, the second one's "follow camera" system doesn't work.. Here's the code
Lets say I have the gun, and I duplicate it (two have the same weapon two times), the new weapon (the clone) doesn't move the character's arms even though it's the exact same tool as the original one.
oh i get it. So can you tell me where the script is?
the script is inside the tool
ping
check reply on my answer