How to make a module script stop script execution?

Hey,

I wanted to know how to make a module script stop execution.
Example:

MODULE:

function module:WaitUntilAvailable()
	while (not self.PMCRRC_Connection['Loaded']) or self.PMCRRC_Connection['Loaded']~=true do
        if self.PMCRRC_Connection['AbortLoading'] then
                ABORT_SCRIPT()
        end
		wait()
	end
	return true
end
SCRIPT:

local module =require(modulepath)
print("Start")
module:WaitUntilAvailable()
print('It should not print this if ABORT_CODE is executed.')

Thanks.

1 Like

Does this fit your needs?

-- module

function module:WaitUntilAvailable()
	while (not self.PMCRRC_Connection['Loaded']) or self.PMCRRC_Connection['Loaded']~=true do
		if self.PMCRRC_Connection['AbortLoading'] then
			return false
		end
		task.wait()
	end
	return true
end
-- script

local module =require(modulepath)
print("Start")
local yield = module:WaitUntilAvailable()

if yield then
	print('It should not print this if ABORT_CODE is executed.')
end

Yes, but I was searching for something that wouldnt need if yield then. If that’s not possible, then I’ll just use that.

1 Like

I guess you could delete the script (personally, just using if yield then is easier)?

Hmmm… What about just an infinite yield, would that cause performance issues?