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

Does anyone know how to stop my Output from saying -Not a Valid Member?

Asked by
Noxnuo 11
4 years ago
Edited 4 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

So my Output is saying that "Humanoid is not a valid member of Workspace" and Humanoid is a valid member of my dummies and my dummies are in the Workspace. So whats up with that. Is Humanoid only a member in my dummies or what? I don't know? Anyways here is my script.

Normal Script for Damage:

1script.Parent.LinkedSwordModel.BladePart.DamagePart.Touched:Connect(function(p)
2    if script.Parent.CanDamage.Value == true then
3        script.Parent.CanDamage.Value = false
4        p.Parent.Humanoid:TakeDamage(20)
5end
6end)

Local Script for Animations:

01local CanAttack = true
02 
03script.Parent.Equipped:Connect(function()
04    local Idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
05    local Slash = script.Parent.Parent.Humanoid:LoadAnimation(script.Slash)
06 
07    Idle:Play()
08end)
09 
10script.Parent.Activated:Connect(function()
11    local Idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
12    local Slash = script.Parent.Parent.Humanoid:LoadAnimation(script.Slash)
13 
14    if CanAttack == true then
15        Slash:Play()
View all 24 lines...
0
Oh yes by the way it says "not a valid member" in the output Noxnuo 11 — 4y
1
Please put all of your code in the code block Despayr 505 — 4y
0
Its in the code brackets now Noxnuo 11 — 4y
0
Yes, the Humanoid Object is only accessible within the Dummy Model. Ziffixture 6913 — 4y

1 answer

Log in to vote
0
Answered by
DesertusX 435 Moderation Voter
4 years ago
Edited 4 years ago

When an instance is a child of a parent, it doesn't make it the child of the parent of its parent. To fix this there are two ways:


1.

Just add the name of your dummy before the Humanoid.

Example:

2nd script: line 4

1local Idle = script.Parent.Parent.Dummy.Humanoid:LoadAnimation(script.Idle)

You should change dummy to the name of your dummies.


2.

Use :FindFirstDescendant("String"). This finds the first descendant named the string inside the ().

Example:

2nd script: line 4

1local Idle = script.Parent.Parent:FindFirstDescendant("Humanoid"):LoadAnimation(script.Idle)

Hope this helps!

0
Thanks! I can now move on! Noxnuo 11 — 4y
0
Always happy to help! DesertusX 435 — 4y
Ad

Answer this question