Is there a way to stop a function, outside of a function? Something like this.
local hum = game.Players.LocalPlayer.Character.Humanoid
function fish()
print("yes")
wait(1)
print("no")
wait(1)
print("yes")
wait(1)
print("no")
end)
spawn(function()
fish()
end)
hum.Died:connect(function()
fish:stop() -- ??
end)
This script is an example. ;-;

2 comments
Try looking at coroutines. https://www.lua.org/pil/9.1.html
You can use
spawn(fish)if fish takes no arguments