Humanoid Is Not A Valid Member Of Workspace?
Asked by
5 years ago Edited 5 years ago
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
05 | function tagHumanoid(humanoid,killer) |
07 | if humanoid and killer then |
09 | local tag = Instance.new( "ObjectValue" ) |
17 | script.Parent.Handle.blade.Touched:connect( function (p) |
19 | local plr = game.Players:GetPlayerFromCharacter(tool.Parent) |
21 | if script.Parent.CanDamage.Value = = true then |
23 | script.Parent.CanDamage.Value = false |
25 | local humanoid = p:FindFirstChild( "Humanoid" ) |
27 | p.Parent.humanoid:TakeDamage(Av) |
29 | tagHumanoid(humanoid, plr) |
33 | script.Parent.CanDamage.Value = true |
35 | if p.Parent.Humanoid.Health < 1 then |
36 | print ( "Player Has Died" ) |