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

Will this script work?

Asked by
Avectus 120
9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I'm trying to make a sword.

Blade = script.Parent.Saber2

damage = 10

Blade.Touched:connect(function(hit)
    hit.Parent:findFirstChild("Humanoid"):TakeDamage(damage)
end)

Will the above code deal damage to another player when hit?

Thanks.

0
Have you tested it? Grenaderade 525 — 9y

1 answer

Log in to vote
-2
Answered by 9 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
Blade = script.Parent.Saber2

damage = 10

Blade.Touched:connect(function(hit)
local human = hit.Parent:FindFirstChild("Humanooid")
    if human then
    human:TakeDamage(damage)
    end
end)
1
Don't forgot to check if the hit is not the player using the sword SurVur 86 — 9y
0
How do you do that? woodengop 1134 — 9y
Ad

Answer this question