Help on stop a function in a loop

hello everyone, I am trying to make the function restart after a remote event has been fired. I have tried to make this and succeed in everything but not the part when u break the function. any help

server script

local die = game.ReplicatedStorage:WaitForChild("Die")
local fol = false
die.OnServerEvent:connect(function(player)
fol = true
end)


function lol()	
if fol == true then
return
end
for i=1, 3, 1 do	
countDown("Starting wave in ... ", intermisson, i)
RoundStartFunction()
stopmenu()
countDown("Fight!!! ", roundtime, 0)
onmenu()
RoundEndFunction()

end
end

spawn(lol)

local script

local die = game.ReplicatedStorage:WaitForChild("Die")

function yo()

die:FireServer()

end
spawn(yo)

Instead of

spawn(yo)

Do

yo()

Also, put a “local” in front of the function yo().

still didnt work . the remote event works but the
if fol == true then
return
end
doesnt work

This should do it

	--Script

	local die = game.ReplicatedStorage:WaitForChild("Die")
	local fol = false

	die.OnServerEvent:Connect(function(player)
		lol()
		fol = true
	end)

	function lol()	
		if fol == true then return end
		for i=1, 3, 1 do	
			countDown("Starting wave in ... ", intermisson, i)
			RoundStartFunction()
			stopmenu()
			countDown("Fight!!! ", roundtime, 0)
			onmenu()
			RoundEndFunction()
		end
	end

	--LocalScript

	local die = game.ReplicatedStorage:WaitForChild("Die")

	function yo()
		die:FireServer()
	end
	yo()

Move spawn(lol) into the die.OnServerEvent clause. You are making and asynchronous operation which runs first after the client fire.