So I have this script, thats a part of my sword. The damage and animation are a little off, so I wanted to add a wait to the damage part. I added it, then it gives an error, for the next line of code. I take it away, and it works perfectly fine. I have no idea why, this has never happened to me before. This is the error 19:52:34.046 - Players.Wilbyte.Backpack.Stick.Script:16: attempt to index field 'Parent' (a nil value). Code:
CanDamage = true script.Parent.Handle.Touched:Connect(function(p) if CanDamage == true then if p.parent:FindFirstChild("Zombie") then wait(.2) p.Parent.Zombie:TakeDamage(20) CanDamage = false end end end)
the wait(.2) you added isn't the problem. The problem is that in line 4, Parent isn't capitalised.
it should be if p.Parent:FindFirstChild("Zombie") then
instead