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

[SOLVED] Why doesn't just this part of my code work? Do I need to use something else?

Asked by 2 years ago
Edited 2 years ago

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.

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

Answer this question