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

can't find the path to .Humanoid - help? (solved!)

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.

2 comments

0

Please do not repost your questions. Be patient.

0

make it more detailed pls

2 answers

✓ Accepted answer

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!

5 comments

0

this didn't really help. the same error shows up, but with Humanoid instead of humanoid. i wanted to tell you that, but there isn't actually a way to reply to comments on this site as far as i know. thanks for the answer, anyway though!

0

Check what you called the Humanoid in your NPC. If you're trying to make a reference to an object which doesn't exist, it will tell you that it is an invalid member.

0

it's not an npc. it's the player. the reason this is a question is that not all players have the same name, so i can't just do cats2324.Humanoid

0

You are presumably referencing the character judging by your code (script.Parent.Humanoid), by the looks of that chunk of code by itself, the script is located directly under the Character. You won't need to know which Player's Humanoid if the script is already in its character, what you said is contradicting yourself. The error you provided is a different problem than what you're saying now.

0

i am incredibly confused. i'm sorry, i'm a slow in the head guy..

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)

2 comments

0

thanks for the help! :)

0

Youre welcome

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