Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I change a local value depending on the outcome of a check?

Asked by 5 years ago

The question above was hard to fit in such a small amount, let me clarify.

1local 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

1local TargetHumanoid = HitPart.Parent.Parent:WaitForChild("Humanoid")

How can I get the script to do this?

Heres the part of the script...

01if not ExplosiveData[1] then
02    if HitPart and HitPart.Parent and HitPart.Transparency < 0.9 then --Test if we hit something
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,
09                                                                            Tagger,
10                                                                            TargetHumanoid,
11                                                                            TargetTorso,
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])
15        else
16            MakeImpactFX(HitPart, HitPoint, Normal, HitEffectData, BulletHoleData)
17        end
18    end

1 answer

Log in to vote
0
Answered by 5 years ago

Yeah... So I actually just forgot a value I needed to add an 'or' to...

Ad

Answer this question