so, let me explain some things first. i have a script that is inside a tool, and that tool is in StarterPack. when I play the game, the tool gets moved to the same group that .Humanoid is in. (my character in Workspace)
the problem here is that is that i don't know what the path to .Humanoid is. if p.Parent doesn't work, then what am i supposed to type in?
here's the error:
21:29:25.502 - humanoid is not a valid member of Folder 21:29:25.504 - Stack Begin 21:29:25.504 - Script Players.peasantvonpeasant.Backpack.WoodenSword.DamageForSwords’, Line 7
(humanoid is not a typo, it's a variable)
and here's the script:
local CanAttack = true script.Parent.Blade.Touched:Connect(function§ if CanAttack == true then CanAttack = false local humanoid = p.Parent:FindFirstChild(“Humanoid”) p.Parent.humanoid:TakeDamage(9) wait(.53) CanAttack = true
end end)
i can give more details too, if you need it. sorry for any grammar mistakes as well, english ain't my first language.
please, if you know how to solve this answer! i've skewered the internet all day and couldn't find anything.
I posted a solution on your last post, but I will answer it this time - The error is telling you that 'humanoid' is an invalid member - in other words, it does not exist in the folder. This is true because the Humanoid object is named 'Humanoid', not 'humanoid', like what you have in your code.
I have commented what and where you went wrong with your code here.
local CanAttack = true script.Parent.Blade.Touched:Connect(function() if CanAttack == true then CanAttack = false local humanoid = p.Parent:FindFirstChild(“Humanoid”) p.Parent.humanoid:TakeDamage(9) --> ERROR: 'humanoid' is an invalid member of folder. wait(.53) CanAttack = true end end)
p.Parent.humanoid does not exist. p.Parent.Humanoid on the other hand, does exist. Humanoid object's are named Humanoid, not humanoid. If you reference 'Humanoid' and not 'humanoid' of p.Parent, it will find it (as shown below)
local CanAttack = true script.Parent.Blade.Touched:Connect(function() if CanAttack == true then CanAttack = false p.Parent.Humanoid:TakeDamage(9) --find 'Humanoid', not 'humanoid'. Done! wait(.53) CanAttack = true end end)
Hope this answers your problem!
local CanAttack = true --add p behind funcution, thats the player who will touch it, then its solved. script.Parent.Blade.Touched:Connect(function(p) --<-- sovled if CanAttack == true then CanAttack = false local humanoid = p:FindFirstChild(“Humanoid”) humanoid:TakeDamage(9) -- <-- solved --> ERROR: 'humanoid' is an invalid member of folder. wait(60*5) -- = 5 min can only in seconds CanAttack = true end end)