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

How can I make a sword or weapon deal damage to multiple Humanoid names?

Asked by
jm34 7
7 years ago

I have 3 different humanoids I want to take damage from my weapons, Humanoid, Enemy, and Marine. I cant get them all to take damage only one at a time. How can I make a weapon damage all of them at once?

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago

You could use the FindFirstChildOfClass function to get any Humanoid, reguardless of their name.

example;

script.Parent.Touched:Connect(function(hit)
    local h = hit.Parent:FindFirstChildOfClass("Humanoid");
    if h then
        h:TakeDamage(20);
    end
end)
0
Thanks man thats exactly what i'm looking for! ill try put it in a sword. jm34 7 — 7y
0
Worked right away! jm34 7 — 7y
Ad

Answer this question