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

Hurting specific parts of the player?

Asked by
Hero_ic 502 Moderation Voter
8 years ago

So I tried to make a script where it gives damage to a specific part of the body but it does not work correctly. Any help? ~Thanks.

    beam.Touched:connect(function(hit)
        local name = hit.Parent.Parent.Name
        if not name then
            local humanoid = hit.Parent:FindFirstChild("Humanoid")
            if not humanoid then
                humanoid = hit.Parent.Parent:FindFirstChild("Humanoid")
            end
            local limbs = hit.Parent:findFirstChild("Right Arm") 
            or hit.Parent:findFirstChild("Right Shoulder")
            or hit.Parent:findFirstChild("Right Hip")
            or hit.Parent:findFirstChild("Right leg")
            or hit.Parent:findFirstChild("Left Hip")
            or hit.Parent:findFirstChild("Left Leg")
            or hit.Parent:findFirstChild("Left Arm")
            or hit.Parent:findFirstChild("Left Shoulder")       
            local chest = hit.Parent:findFirstChild("Torso")
            local head = hit.Parent:findFirstChild("Head")
            if chest then
                if humanoid then
                    humanoid:TakeDamage(props.chestDamage)
                end
            end
            if head then
                if humanoid then
                    humanoid:TakeDamage(props.headDamage)
                end
            end
            if limbs then
                if humanoid then
                    humanoid:TakeDamage(props.limbDamage)
                end
            end
        end
    end)

1 answer

Log in to vote
-1
Answered by 8 years ago

You've messed up on your capitals. Lua scripting is case-sensitive. It's FindFirstChild:()

0
It still does not work Hero_ic 502 — 8y
0
Also, findFirstChild is a deprecated version of FindFirstChild. They do the exact same thing. M39a9am3R 3210 — 8y
Ad

Answer this question