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

How do I script a sword without handle?

Asked by
Svelex 0
6 years ago

So I made a sword without handles,it works fine. I can equip and unequip, but the thing is how would I make a script to damage humanoid if the sword does not have a handle?

2 answers

Log in to vote
0
Answered by 6 years ago

Are there any parts in the sword? I would make a invisible part surrounding the entire sword and have a Touched event on the part.

0
I did that but it didn't work since my swords aren't modeled, they're union into 1 part Svelex 0 — 6y
Ad
Log in to vote
0
Answered by
tantec 305 Moderation Voter
6 years ago

Well, if you have parts in the sword that touches someone when you hit them then you can use the basic:

for _,v in pairs(sword:GetChildren()) do
v.Touched:connect(function(hit)
player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
player.Character.Humanoid:TakeDamage(the amount of damage you want)
end
end)
end

I hope this answered your question!

0
Also, if you're using a union part, you can just make a variable stating where it is and used the same .Touched function as I used except changing "v" with the variable name that you have made for the Union tantec 305 — 6y

Answer this question