Every time I run through my code the function does not continue passed the first if statement. Even when players has values it still won't continue. I have even tried changing
players
to
players[1]
Here's the code:
playersService = game:GetService("Players")
ServerScript = game:GetService("ServerScriptService")
function testPlayerDeath()
local players = playersService:GetChildren()
if players == not nil then
print("if done")
for _, players in pairs(players) do
script.ChildAdded:connect(function()
print("passed")
if script:FindFirstChild(players.Name) == players.Name then
print("passed2")
local Value = script:WaitForChild(players)
if Value.Value == true then
print("passed3")
print("Current Selection: "..players)
onPlayerDeath(players)
failed = false
return failed
else
failed = true
return failed
end
end
end)
end
else
failed = true
return failed
end
end
while true do
wait()
testPlayerDeath()
print("failed?: ")
print(failed)
end
if you find anything confusing or wrong in my code please leave a comment.
edit: the use of the return is simply for debugging

1 comment
Your code connects the script.ChildAdded event infinitely. Take that part out of the function. Also, why aren't you using the Died function of humanoid? It'll also get hung on line 13, especially as a table can't be a child.