I'm trying to make an enemy NPC script, everything else in the script works except this part of the code:
for _, Child in pairs(script.Parent:GetChildren()) do
if Child:FindFirstChild("DangerZone") then
Child.Touched:connect(Hit)
print("Player has been hit")
end
end
I'm still learning how GetChildren works, so sorry if I'm using it wrong or if I need to use something else.

5 comments
Tell me if I need to post the whole script, sorry for the inconvenience.
Is Hit a custom function you made? Or is it first called there?
Yes, Hit is a function before this line of code. It's a function that damages the player.
i dont see a problem here, can u show us the hit function?
I've posted the whole script instead