Hey! So basically what I am trying to achieve here is when some player leaves the game then the function will be paused by using the
coroutine.yield() function, however when I do this I want to be able to stop the function (which I just did) but also restart the function after me stopping it. So is there any way to achieve this? I’ve been researching everywhere about coroutines and there doesn’t seem to be a function that can restart a function, if I try using a boolean value to check whether its true or not the script will just continue where it was paused at.
Here is an example of a coroutine I made:
local Thread = coroutine.create(function() -- game code game.Players.PlayerRemoving:Connect(function(player) if player.Name == mainPlayer then coroutine.yield("threadPaused") -- How do I restart the function again so that the game will restart when the main player dies? else end end) end) coroutine.resume(Thread)