The question above was hard to fit in such a small amount, let me clarify.
local TargetHumanoid = HitPart.Parent:WaitForChild("Humanoid")
In the situation if the bullet hits a body part, were all good. But when it hits an accessory or morph part it wont do damage because it has to go up an extra parent to find the Humanoid
local TargetHumanoid = HitPart.Parent.Parent:WaitForChild("Humanoid")
How can I get the script to do this?
Heres the part of the script...
if not ExplosiveData[1] then
if HitPart and HitPart.Parent and HitPart.Transparency < 0.9 then --Test if we hit something
local TargetHumanoid = HitPart.Parent:FindFirstChild("Humanoid") or HitPart.Parent.Parent:FindFirstChild("Humanoid")
local TargetTorso = HitPart.Parent:FindFirstChild("HumanoidRootPart") or HitPart.Parent:FindFirstChild("Head")
local Tagger = game.Players:GetPlayerFromCharacter(Tool.Parent)
if TargetHumanoid and TargetHumanoid.Health > 0 and TargetTorso then
MakeBloodFX(HitPart, HitPoint, Normal, BloodEffectData, FleshHoleData)
game.ReplicatedStorage:WaitForChild("InflictTarget"):FireServer(Tool,
Tagger,
TargetHumanoid,
TargetTorso,
(HitPart.Name == "Head" and DamageData[3]) and DamageData[1] * DamageData[2] or DamageData[1],
{Misc[1],Misc[2],Misc[3]})
Tool.GunScript_Local:FindFirstChild("MarkerEvent"):Fire(HitPart.Name == "Head" and DamageData[3])
else
MakeImpactFX(HitPart, HitPoint, Normal, HitEffectData, BulletHoleData)
end
end
