local Sword = script.Parent
local function onTouch(partOther)
local humanOther = partOther.Parent:FindFirstChild("Humanoid")
if not humanOther then return end
if humanOther.Parent == Sword then return end
humanOther:TakeDamage(5)
end
local function slash()
local str = Instance.new("StringValue")
str.Name = "toolanim"
str.Value = "Slash"
str.Parent = Sword
end
Sword.Activated:Connect(slash)
Sword.Handle.Touched:Connect(onTouch)
✓ ANSWER ACCEPTED
I'm making a fighting game, but the swords won't work. Please help?
2 answers
✓ Accepted answer
What do you mean it doesn't work. I tested it and it works perfectly fine. Make a tool in StarterPack, add a part to that tool(or your your sword mesh/model, just make sure the handle is a part), name the part "Handle", add a normal script to the tool, paste your code in the script. Test it.
I just needed to change the damage script in the sword to a local script!
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
I didn't put it in starterPack, I put it in a textbutton in starterGUI because I'm making a button to get a sword. Do you know why it won't work? Thanks.
Try putting it in StarterPack and see what happens, and also, what happens when you click the textbutton? Is the entire sword, including the script, cloned into the player's backpack? If so, what kind of script are you using for the sword, is it a server script or a localscript(these are the ones with a person's head on it)?
I did try putting it in starterPack, and it did work, and when I click the text button, it clones everything into it and the animation, but not the original sword animation. I made the other animation myself. Also, I'm using a localScript for the textbutton and the damage script didnt load but the animation script did, and I'm using a normal script for the sword to damage
Nevermind, I fixed it. Thank you so much!
No problem!