Im trying to make a simple weapon system however my Mouse.Target only detets the arm limbs wherever i shoot it.
if Target ~= nil then
if Target ~= Character then
if Target and Target.Parent.Humanoid then
if Target.Parent:WaitForChild("Left Arm") or Target.Parent:WaitForChild("Right Arm") then
Target.Parent.Humanoid:TakeDamage(15)
print("Hit Arm Limb")
elseif Target.Parent:WaitForChild("Left Leg") or Target.Parent:WaitForChild("Right Leg") then
Target.Parent.Humanoid:TakeDamage(15)
print("Hit Leg Limb")
elseif Target.Parent:WaitForChild("Torso") then
Target.Parent.Humanoid:TakeDamage(25)
print("Hit Torso")
elseif Target.Parent:WaitForChild("Head") then
Target.Parent.Humanoid:TakeDamage(1000)
print("Hit Head")
end
end
end
end
i’ve puit bullet holes to show the areas that were hit, and its still only picking up the arm limbs?
Well that’s because a character will always have arms, and you check if the character has arms. Did you mean to check if its name was equal to Right Arm?
if target.Name == "Left Arm" then
Also no need to check if target was the character, just assign it to Mouse.TargetFilter
You are checking if Target.Parent has a Left Arm or Right Arm. Since a rig does have those parts, it will print("Hit Arm Limb"). Try this instead:
local ArmParts = {"Left Arm", "Right Arm"}
local LegParts = {"Left Leg", "Right Leg"}
if table.find(ArmParts, Target.Name) then
Target.Parent.Humanoid:TakeDamage(15)
print("Hit Arm Limb")
elseif table.find(LegParts, Target.Name) then
Target.Parent.Humanoid:TakeDamage(15)
print("Hit Leg Limb")
elseif Target.Name == "Torso" then
Target.Parent.Humanoid:TakeDamage(25)
print("Hit Torso")
elseif Target.Name == "Head" then
Target.Parent.Humanoid:TakeDamage(1000)
print("Hit Head")
end
You should probably just write out the equality instead of table.find, because table.find will be much slower than an equality and you don’t make two extra tables!