Stopping a function that is inside another function

I used chat gpt

local Condition = true

local function Function1()
	local function Function2()
		if Condition == true then
			return true
		end
	end
	if Function2() then
		return
	end
	print("Still Running")
end

Function1()

Use chat gpt before ask here. also don’t use chat gpt before think and try about it else you will be useless programmer

He doesn’t want that, he doesn’t want to use functions internally inside the Function1 function.

Did it work or do you still need help?

you could use threads maybe?

local thread
local function Function1()
  thread = task.spawn(function()
     local function Function2()
         If Condition == true then
          --Stop The functions here
            task.cancel(thread)
             return
         end
     end
--Doesnt print When both functions are stopped
print("Still Running")
   end)
end

He doesn’t want to use many functions.

Fair enough good luck on this :sob:

Thanks for your help your method worked

No problem

C H A R A C T E R S