Does calling a function in a function run synchronous?

Sorry for the confusing title. I just wanted to know if when a script executes like so

local function doSomething()
--some long code that does stuff
return somevariable
end

remote:Connect(function()
    local var = doSomething()
-- do some more stuff <-- Would this code execute before the variable can be returned?
end)

Calling a function is inherently synchronous.

1 Like
function test()
	local number = add(1,1)
	
	print(number)
end

function add(a,b)
	print("add function")
	task.wait(5)
	return a+b
end

test()

In a situation like this the “test” function would wait until the value is returned before printing number.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.