Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Returning a value without ending the function?

Is it possible to run a function and return a value while code is still being executed within? If so, how would I go about doing so?

1 comment

0

Happy 100 rep milestone(;

1 answer

✓ Accepted answer

Technically speaking, no there isn't any way to use the return statement in a function without discontinuation occurring.


But there is an alternative. You can just define a value before running the function, and have a parameter inside the function which will be set to whatever value you want


Example;

function derp(argument, variableParam)
	--code
	variableParam = 0
	--code
end

local a = 1
derp(argument,a)

Now,'a' will be set to 0 whenever the function derp runs.. so it's kinda like returning a value(:

This discussion is preserved as it was. New answers, comments, and votes are closed.