Hello, I am having issues with my script which I cannot solve myself. This problem I am referring to is that the Humanoid.Died Event fires as many times as how many consecutive deaths you have avoided once you die. The script looks like this:
local players = game:GetService("Players")
local playersInGame = {}
script.Parent.ClickDetector.MouseClick:Connect(function()
print("round started")
for _, player in pairs(players:GetPlayers()) do
table.insert(playersInGame, player)
player.Character:WaitForChild("Humanoid").Died:Connect(function()
print(player.Name.. " died")
table.remove(playersInGame, table.find(playersInGame, player))
end)
end
task.wait(5)
print("round ended")
playersInGame = {}
end)
Any help will be appreciated!
I could probably like disable the event when the round ends only if I knew how to.
also u might wanna use debounce to disable anymore lines getting pass the first line in mouseclick event when round is ongoing, like
local Debounce = false
script.Parent.ClickDetector.MouseClick:Connect(function()
if Debounce == true then return end
Debounce = true
Debounce = false -- when round ended
end)