i need a code when a npc die it need to restart a loop
while true do
--More Code that im not going to show cause it's just teleporting the player and stuff.
game.Workspace.NPC:WaitForChild("humanoid").Died:Connect(function()
for i = 1, #Players do
if Players[i].Playing.Value == true then
table.insert(Winners, Players[i].Name)
Players[i].leaderstats.Money.Value = Players[i].leaderstats.Money.Value + 10
Players[i].leaderstats.Wins.Value = Players[i].leaderstats.Wins.Value + 0.5
Players[i].Character.Humanoid.Health = 0
Players[i].Playing.Value = false
ChangeText('GAME OVER!')
end
end
end)
end

2 comments
If you want, you can yield the loop until the humanoid dies and rerun your code, but I don't think that's what you want to do.
yes, you need to connect the Humanoid.Died somewhere out of the loop, and then turn the loop into a function which is called. Or use :Wait(), if that's what you need.