I’m trying to end this function when the humanoid died event fires but I can’t figure out what I’m doing or how to do it. As far as I know, simply returning end in the event won’t work. Is there another way I can end the function and break the loop when the event fires?
["SinglePlayer"] = function(tileTable, player)
local humanoid = player.Character:FindFirstChild("Humanoid")
humanoid.Died:Connect(function()
--idk what to put here lol
return --something idk
end)
detectClicks(tileTable)
local repeatTimes = #tileTable
for i = 1, repeatTimes do
local c = tileTable[math.random(1, #tileTable)]
local fadeOut = tservice:Create(c, tinfoOut, {Transparency = 1})
if c then
fadeOut:Play()
wait(tinfoOut.Time)
c:Destroy()
end
wait(5)
end
end
I agree with @L_umin. I would think that you need to break where it is being looped (if they are dead), but is the function called once and the loop keeps the function running or is the function being called multiple times?
I got it working but I’m just wondering now whether you recommend checking the humanoid’s health, which I am doing currently, or if I should set a boolean value and switch it to false when the player dies.