So my goal is to make it so that when you hit an enemy he plays the animation that you hit him. As I understand it, I need to first get a humanoid NPC, and then play there animation. I was told that I should use touched, so when you touch the enemy you can add it to a variable, right?
local function OnTouched(otherPart, Head, Torso)
print("Touch started: " .. otherPart.Name)
if otherPart == Head or Torso then
wait(0.3)
print("It's working")
print(Head.Parent)
else
print("Try to find better")
end
end
This is what I wrote a script, but it does not work for me I do not understand how to distinguish between hitting the party from hitting the NPC. Immediately say that the script is local and is located at the tool.
And then how do I write what I hit into a variable?