Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Will this script work?

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.

1 comment

0

Have you tested it?

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

2 comments

1

Don't forgot to check if the hit is not the player using the sword

0

How do you do that?

This discussion is preserved as it was. New answers, comments, and votes are closed.