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:

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

Local Script for Animations:

local CanAttack = true

script.Parent.Equipped:Connect(function()
    local Idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
    local Slash = script.Parent.Parent.Humanoid:LoadAnimation(script.Slash)

    Idle:Play()
end)

script.Parent.Activated:Connect(function()
    local Idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
    local Slash = script.Parent.Parent.Humanoid:LoadAnimation(script.Slash)

    if CanAttack == true then
        Slash:Play()
        Idle:Stop()
        CanAttack = false
        wait(1)
        Slash:Stop()
        Idle:Play()
        CanAttack = true
        script.Parent.Value = true
end
end)
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

local 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

local 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