Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

4 comments

0

Oh yes by the way it says "not a valid member" in the output

1

Please put all of your code in the code block

0

Its in the code brackets now

0

Yes, the Humanoid Object is only accessible within the Dummy Model.

1 answer

✓ Accepted answer

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!

2 comments

0

Thanks! I can now move on!

0

Always happy to help!

This discussion is preserved as it was. New answers, comments, and votes are closed.