I am attempting to make realistic arms for my gun. I could have added this to the rest of my script but I am lazy and my other script is quite a mess.
I added this script to make the head look up and down, therefore, moving the fake arms in the direction of the camera.
When you equip the weapon 3 time the player dies. It is erroring on line 15 saying that I am attempting to index global kneck a nil value.
local tool = script.Parent
local equipped = false
local weld = Instance.new("Weld")
function equip()
player = game.Players:GetPlayerFromCharacter(tool.Parent)
local torso = tool.Parent:FindFirstChild("Torso")
local HCF = tool.Parent.Head.CFrame
head = tool.Parent:FindFirstChild("Head")
kneck = torso:FindFirstChild("Kneck")
local equipped = true
weld.Parent = torso
weld.Part0 = torso
weld.Part1 = head
kneck.Part1 = nil
end
function unequip()
equipped = false
weld.Parent = nil
kneck.Part1 = head
end
while equipped == true do
wait()
weld.C1 = player.CurrentCamera.CFrame.lookVector -- This is not working either so any additional help here would be a nice bonus.
end
tool.Equipped:connect(equip)
tool.Unequipped:connect(unequip)
