Ok so my sword script is being weird. Sometimes my sword takes damage on the player who takes it and sometimes it doesn't and says "Humanoid is not a valid member of Workspace" does anyone know what is wrong with my script?

My script:

script.Parent.DamagePart.Touched:Connect(function(p)
	if script.Parent.CanDamage.Value == true then
	script.Parent.CanDamage.Value = false
	p.Parent.Humanoid:TakeDamage(10)
	wait(0.8)
	script.Parent.CanDamage.Value = true
	end
end)



1 comment

0

you should add an if statement saying if p.Parent.Humanoid then... that should fix the errors