Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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.

0
Please do not repost your questions. Be patient. DeceptiveCaster 3761 — 4y
0
make it more detailed pls mateja1119 0 — 4y

2 answers

Log in to vote
1
Answered by
pidgey 548 Moderation Voter
4 years ago

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!

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! User#28022 0 — 4y
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. pidgey 548 — 4y
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 User#28022 0 — 4y
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. pidgey 548 — 4y
0
i am incredibly confused. i'm sorry, i'm a slow in the head guy.. User#28022 0 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
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)
0
thanks for the help! :) User#28022 0 — 4y
0
Youre welcome User#27824 0 — 4y

Answer this question