Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

01Av = 15 --Attack Value
02 
03tool = script.Parent
04 
05function tagHumanoid(humanoid,killer)
06 
07    if humanoid and killer then
08 
09        local tag = Instance.new("ObjectValue")
10        tag.Name = "creator"
11        tag.Value = killer
12        tag.Parent = humanoid
13    end
14 
15end
View all 41 lines...

1 answer

Log in to vote
1
Answered by
IcyMizu 122
5 years ago
Edited 5 years ago

You dont check if what it touches is a player so if it isnt a player it trys to find a thing u would only find in a player

01Av = 15 --Attack Value
02 
03tool = script.Parent
04 
05function tagHumanoid(humanoid,killer)
06 
07    if humanoid and killer then
08 
09        local tag = Instance.new("ObjectValue")
10        tag.Name = "creator"
11        tag.Value = killer
12        tag.Parent = humanoid
13    end
14 
15end
View all 41 lines...
0
Now the script won't do damage to the player!? Jomeliter 55 — 5y
0
It doesnt? IcyMizu 122 — 5y
0
It doesn't throw up the "Humanoid Is Not A Valid Member Of Workspace" error, but it doesn't deal damage anymore Jomeliter 55 — 5y
0
now? IcyMizu 122 — 5y
View all comments (3 more)
0
it works, thx! Jomeliter 55 — 5y
0
Can u accept the answer pls? IcyMizu 122 — 5y
0
o, my bad forgot to do that lol Jomeliter 55 — 5y
Ad

Answer this question