I'm attempting to make a gun, everything works perfectly besides the damage. The damage will only sometimes work, and I can't find what is wrong. Sorry if my indentation isn't good. Here is the snippet with the damage:
bullet.Touched:Connect(function(hitted) if hitted.Parent.Name ~= Player and hitted.Name ~= "Handle" and hitted.Parent:FindFirstChild("Humanoid") ~= nil then if hitted.Name == "UpperTorso" or hitted.Name == "LowerTorso" then hitted.Parent.Humanoid:TakeDamage(Damage) elseif hitted.Name == "RightUpperArm" or hitted.Name == "RightLowerArm" or hitted.Name == "RightHand" or "LeftUpperArm" or hitted.Name == "LeftLowerArm" or hitted.Name == "LeftHand" then hitted.Parent.Humanoid:TakeDamage(Damage - 10) elseif hitted.Name == "RightUpperLeg" or hitted.Name == "RightLowerLeg" or hitted.Name == "RightFoot" or "LeftUpperLeg" or hitted.Name == "LeftLowerLeg" or hitted.Name == "LeftFoot" then hitted.Parent.Humanoid:TakeDamage(Damage - 5) elseif hitted.Name == "Head" or hitted:IsA("Accessory") then for i = HeadshotSurival,20 do if i <= HeadshotSurival then hitted.Parent.Humanoid:TakeDamage(HeadshotDamage) else hitted.Parent.Humanoid:TakeDamage(hitted.Parent.Humanoid.Health) end end end end end)
Each limb has a different amount of damage, and the headshot has a change to survive. (This is in a serverscript and is fired by a remotevent)