Loop call a function, waits for return?

Hiwi! Quick noob question…

Doing a for loop, call a different function, wait for the return data of that function before continue with the loop, getting the new data and continue with the loop… sorry Im so bad at explaining…

Here’s a quick funny “example” :v

local function wakamole(gotTaco)
	local tacoPower = gotTaco + 50
	-- SEND NEW TACO TO THE LOOP
	return tacoPower
end

for c = 1, 10 do
	local taco = spice * 2
	-- SEND THE TACO TO THE WAKAMOLE FUNCTION
	wakamole(taco)
	-- WAIT FOR WAKAMOLE FUNCTION TO FINISH BEFORE TO CONTINUE
	-- USING NEW TACO DATA
	local FromWakamole = newTaco
	print("new value of taco: ", newTaco)
end

Can someone please show me how to do it correctly?.. u ,u

Thank you so much for reading :3

1 Like

local functions can only be called within the function just use the function as

function wakamole(gotTaco)
	local tacoPower = gotTaco + 50
	-- SEND NEW TACO TO THE LOOP
	return tacoPower
end
1 Like

You can just have a variable equal to a function, if thats what your asking

local function nnn()
return 69
end

local number = nnn()
print(number)--69
1 Like

I think you just need to store what the function returns to be able to use it later

for c = 1, 10 do
	local taco = spice * 2

	-- SEND THE TACO TO THE WAKAMOLE FUNCTION
	local newTaco = wakamole(taco) -- store what the function returns in a variable

	-- USING NEW TACO DATA
	local FromWakamole = newTaco

	print("new value of taco: ", newTaco)
end
1 Like

Because this post was stopped for verification since yesterday… (idk why…) I had to figure it out by myself yesterday xD
Thank you so much, yeah the answer was so obvious xD, thanks anyway :3