So I have this script inside my sword, and it seems to throw up an error when it touches anything other than a player, and I can't seem to find a way to make it still do damage to a humanoid if it touches something that doesn't contain a Humanoid
I've tried WaitForChild, but it throws up an infinite yield error
Av = 15 --Attack Value
tool = script.Parent
function tagHumanoid(humanoid,killer)
if humanoid and killer then
local tag = Instance.new("ObjectValue")
tag.Name = "creator"
tag.Value = killer
tag.Parent = humanoid
end
end
script.Parent.Handle.blade.Touched:connect(function(p)
local plr = game.Players:GetPlayerFromCharacter(tool.Parent)
if script.Parent.CanDamage.Value == true then
script.Parent.CanDamage.Value = false
local humanoid = p:FindFirstChild("Humanoid")
p.Parent.humanoid:TakeDamage(Av)
tagHumanoid(humanoid, plr)
wait(1)
script.Parent.CanDamage.Value = true
if p.Parent.Humanoid.Health < 1 then
print("Player Has Died")
end
end
end)

7 comments
Now the script won't do damage to the player!?
It doesnt?
It doesn't throw up the "Humanoid Is Not A Valid Member Of Workspace" error, but it doesn't deal damage anymore
now?
it works, thx!
Can u accept the answer pls?
o, my bad forgot to do that lol