Using a script online.
script.Parent.blade.Touched:connect(function(p)
if script.Parent.CanDamage.Value == true then
p.Parent.Humanoid:TakeDamage(20)
script.Parent.CanDamage.Value = false
end
end)
The NPC humanoid part is named 'NPC'
IN THE script it says "Humanoid is not recognized"
but when I use
p.Parent.Henchmen.NPC:TakeDamage(20)
(the model is named henchmen and the humanoid part is named 'NPC')
When I swing the sword, it actually takes damage from the NPC far away without even touching it.
Thanks for help in advance.
You need to use something called GetPlayerFromCharacter. If we get a player, we ignore it, else we kill it. Don't rename your humanoid, somethings don't work when you rename the Humanoid.
script.Parent.Blade.Touched:Connect(function(part) if part.Parent:FindFirstChild("Humanoid") then if game:GetService("Players"):GetPlayerFromCharacter(part.Parent) then -- make sure we can get the player from it local plr = game:GetService("Players"):GetPlayerFromCharacter(part.Parent) if plr then -- do nothing, it's a Player's character elseif not plr then -- just to make sure it's not a player part.Parent.Humanoid:TakeDamage(20) end end end end)