-- i have a round system and i have a for loop nested in a while loop constantly
-- checking if a player died, then removing it from a table called "alive players".
-- even when i don't die, the output constantly prints that i died. The stranger thing is
-- it doesn't remove me from the table. Could someone help?
while wait() do
for i,e in pairs(workspace:GetChildren()) do
if e:FindFirstChild("HumanoidRootPart") then
if e.Humanoid.Died ~= nil then
table.remove(alivePeople,i)
print(tostring(e).." DIED")
print(#alivePeople)
end
if #alivePeople == 1 then
print(tostring(e).. " WON")
game:GetService("StarterGui").ScreenGui.TextLabel.Text = (e.Name.." Won!")
timer.Value = 3
break
end
end
end
end
✓ ANSWER ACCEPTED
Condition runs even if it's true?
1 answer
✓ Accepted answer
Instead of saying:
if e.Humanoid.Died ~= nil then
Try this:
if e.Humanoid.Health <= 0 then
--Everything else
The reason that this is erroring is because you are trying to assign an Event to a bool value (true/false). You cant do that. So, we can check to see if the humanoids health (a numberValue) is less then 0 (because if it is under 0 then roblox kills the player automatically, so we know that they died.)
1 comment
0
thanks for the help!
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Humanoid.Diedis an event, not a boolean value.since e.Humanoid.Died is an event, the event exists, therefore it's like saying "if e == true then", thus always being true