So I'm trying to make a basic non-viewmodel gun kit that has the arms that point to where your camera is looking, taking the tool with themselves and thus creating an effect that points your gun to where you're looking, I found this random script that previously was made for only rotating the right arm, but I re-purposed it, unfortunately by adding the left arm I messed something up, the right arm which was added originally works fine, but the left one is going.. backwards. Check it out:
https://gyazo.com/333ecb883cad47c4ccc8bee0cccc998a
Script here:
repeat wait() until workspace:findFirstChild(game.Players.LocalPlayer.Name)
wait()
local cam = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local char = player.Character
local hastool = false
local armweld = player.Character.Torso["Right Shoulder"]
local armweld2 = player.Character.Torso["Left Shoulder"]
local origarmweldcf = armweld.C0
local origarmweldcf2 = armweld2.C0
local basearmweldcf = origarmweldcf + Vector3.new(0,0.25,-0.25)
local basearmweldcf2 = origarmweldcf2 + Vector3.new(0,0.25,-0.25)
local baseheadweldcf = char.Torso.Neck.C1
local heading, attitude, bank
function holdingtool()
for _,instance in ipairs(char:GetChildren()) do
if instance:IsA("Tool") then
return true
end
end
end
cam.Changed:connect(function()
local sx, sy, sz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = cam.CoordinateFrame:components()
heading = math.atan2(m02, m22)
attitude = math.asin(-m12)
bank = math.atan2(m10, m11)
if hastool then
armweld.C0 = basearmweldcf*CFrame.Angles(0,0,attitude)
armweld2.C0 = basearmweldcf2*CFrame.Angles(0,0,attitude)
end
char.Torso.Neck.C1 = baseheadweldcf*CFrame.Angles(attitude,0,0)
end)
char.ChildAdded:connect(function(child)
if child:IsA("Tool") then
hastool = true
armweld.C0 = basearmweldcf*CFrame.Angles(0,0,attitude)
armweld2.C0 = basearmweldcf2*CFrame.Angles(0,0,attitude)
end
end)
char.ChildRemoved:connect(function()
wait()
if not holdingtool() then
hastool = false
armweld.C0 = origarmweldcf
armweld2.C0 = origarmweldcf2
end
end)
