I have made a ModuleScript (which is used for payouts) which runs on a 'while true do' loop and every minute it adds a specified number to the existing number in both the player's leaderstats and to the player's cash display simultaneously.
This whole system is tied to a job system, within the job system there is also a button which when pressed, it causes you to leave the current job and is supposed to remove the payout script. However, when it is pressed the payout continues to run even though the folder it is in gets destroyed.
Here is the code for the payout script:
local module = {game.Players:FindFirstChildOfClass("Player").Jobs.CandyShopWorker}
payCheckAmount = 12
local function CandyShopWorkerPayout()
module[1].Value = true
if script.Parent.Parent.ModuleOriginals.CandyShopWorkerPayout.IsThereAlreadyAPayout.Value == true then
while true do
wait(60)
game.Players:FindFirstChildOfClass("Player").leaderstats.BloxCoins.Value = game.Players:FindFirstChildOfClass("Player").leaderstats.BloxCoins.Value+payCheckAmount
game.Players:FindFirstChildOfClass("Player").PlayerGui.BloxCoinsUI.bloxcoinsUIFrame.currencyAmount.Text = game.Players:FindFirstChildOfClass("Player").leaderstats.BloxCoins.Value
end
else
print("payout exists, no payout being paid out...badum tsss")
end
end
CandyShopWorkerPayout()
return module
(Just click view source if any parts of the code are cut out and whatnot)

4 comments
No it's not?
i dont mead literally copied but doesnt the table you return in the module live on in the requiring script after the modules been deleted
mean*
Well, your answer somewhat helped in a way I guess, not sure if it was truly the answer that aided me to fix my payout system. Anyway, thanks for bringing your attention to my post.