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)
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!