Calling function with a loop acts differently when the function has loop in it

Hello everyone I am having a slight problem with my module script for some reason it acts weird when it is called multiple times by a loop outside of the function but when the loop is inside the function it works as intended is there any way to prevent this from happening?

Example of problem:


function Module:NewCall()
self:OnStart()
	-- other  module code
end

task.spawn(function()
repeat
Module:NewCall()
	RunService.Heartbeat:Wait()
until not true
end)
-- Above works a bit odd
-- Below works as intended
function Module:NewCall()
	repeat
	self:OnStart()
	-- other module code
		RunService.Heartbeat:Wait()
	until not true
end

task.spawn(function()
Module:NewCall()
end)

Is there any reason was to why this happens and how to fix it.

1 Like

I figured it out for now, for some reason it was having it being returned on the function that was being looped outside.