How can I change a local value depending on the outcome of a check?
The question above was hard to fit in such a small amount, let me clarify.
1 | 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
1 | local TargetHumanoid = HitPart.Parent.Parent:WaitForChild( "Humanoid" ) |
How can I get the script to do this?
Heres the part of the script...
01 | if not ExplosiveData [ 1 ] then |
02 | if HitPart and HitPart.Parent and HitPart.Transparency < 0.9 then |
03 | local TargetHumanoid = HitPart.Parent:FindFirstChild( "Humanoid" ) or HitPart.Parent.Parent:FindFirstChild( "Humanoid" ) |
04 | local TargetTorso = HitPart.Parent:FindFirstChild( "HumanoidRootPart" ) or HitPart.Parent:FindFirstChild( "Head" ) |
05 | local Tagger = game.Players:GetPlayerFromCharacter(Tool.Parent) |
06 | if TargetHumanoid and TargetHumanoid.Health > 0 and TargetTorso then |
07 | MakeBloodFX(HitPart, HitPoint, Normal, BloodEffectData, FleshHoleData) |
08 | game.ReplicatedStorage:WaitForChild( "InflictTarget" ):FireServer(Tool, |
12 | (HitPart.Name = = "Head" and DamageData [ 3 ] ) and DamageData [ 1 ] * DamageData [ 2 ] or DamageData [ 1 ] , |
13 | { Misc [ 1 ] ,Misc [ 2 ] ,Misc [ 3 ] } ) |
14 | Tool.GunScript_Local:FindFirstChild( "MarkerEvent" ):Fire(HitPart.Name = = "Head" and DamageData [ 3 ] ) |
16 | MakeImpactFX(HitPart, HitPoint, Normal, HitEffectData, BulletHoleData) |