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

How can I get this to wait for children before continuing?

Asked by 1 year ago

Hello. I made glasses that detect all player’s location, health, stats, etc.

The stats, icons, buttons, etc. are in Gui form and are located in the playergui of the player.

Each time a player dies, their respective Gui tag disappears.

Each time an NPC or Player spawns, I want to add a tag to them as well. So, anytime someone dies, they respawn with a tag.

Im using…

workspace.ChildAdded:Connect(function(child)

if child:FindFirstChild(“Humanoid”) then

— Code to add tag goes here

end)

I keep getting “Humanoid is not a valid member…” How can I make this work for any model added that has a humanoid?

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

I think WaitForChild fixed the problem

workspace.ChildAdded:Connect(function(child)

    if child:WaitForChild(“Humanoid”) then

    — Code to add tag goes here

    end)

Ad

Answer this question