So my last question I accidentally made it seem like I was trying to do something else.. I am not trying to target multiple children actually. I am trying to target a child of several different children.
local wasTouched = false local npcScript = game.Workspace:FindFirstChild("PathNPC").NPC:FindFirstChild("Walk") part.Touched:Connect(function(hit) if not wasTouched then wasTouched = true local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then npcScript.Disabled = false end wasTouched = false end end)
This is the script I am trying to fix.
local npcScript = game.Workspace:FindFirstChild("PathNPC").NPC:FindFirstChild("Walk")
This is what I believe to be my error. here I tried to target the script "Walk" but I am not experienced with lua at all.
What am I doing wrong? The script is under Workspace, then PathNPC, then NPC. / Its parent is NPC, NPC's parent is PathNPC, and PathNPC's parent is Workspace.
Problem was that if you run that code at the start of the game, the children may have not had enough time to be created so FindFirstChild("childName") wont find anything.
Do you need to confirm that the npcScript is a children of game.Workspace.PathNPC.NPC ? If not just type:
local npcScript = workspace:WaitForChild("PathNPC"):WaitForChild("NPC"):WaitForChild("Walk")