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. ;-;
Something like:
local player = game:GetService('Players').LocalPlayer local char = player.Character or player.CharacterAdded:Wait() local hum = char:FindFirstChildWhichIsA('Humanoid') function startFish() local stop = false spawn(function() if stop then return end print('yes') wait(1) if stop then return end print('no') wait(1) if stop then return end print('yes') wait(1) if stop then return end print('no') end) return function() stop = true end end local stopFish = startFish() hum.Died:connect(stopFish)
Explanation:
c: