Bindable Event Not Firing

Hello.

I’ve got this while loop running, which runs a module. Inside that module, there is a timer loop, which at a certain moment IntValue has reached a number, it stops. Now I fire a bindable event from that time, that when it connects inside the while loop, it fires another module. For some reason it won’t connect.

While loop code

while true do

	repeat 
		local NUmPlayers = Plrs:GetPlayers()
		
		wait(CTFSettings.CheckInterval)
	until #NUmPlayers >= CTFSettings.MinimumPlayersRequired 
	
	CTFManager.Begin()
	CTFEnd.Event:Connect(function(EndState)
		print('l')
		local EndStatus = CTFDisplayManager.GetEndStatus(EndState)
		print(EndStatus)
	end)
	print('Okie')
	CTFManager.ResetMap()
	
	wait(CTFSettings.CTFSettings)
end 

I’ve tried everything, even sending another module inside the module where the timer is, which then fires another bindable event to a script which fires the original event. Still no connection or anything.

Any help is appreciated.

Thanks!

1 Like

The problem is how you’re handling the BindableEvent firing. Instead of having it all in one big loop you should do something like this:

CTFEnd.Event:Connect(function(EndState)
	print('l')
	local EndStatus = CTFDisplayManager.GetEndStatus(EndState)
	print(EndStatus)
end)

while true do
    repeat 
		local NUmPlayers = Plrs:GetPlayers()
		
		wait(CTFSettings.CheckInterval)
	until #NUmPlayers >= CTFSettings.MinimumPlayersRequired 
	
	CTFManager.Begin()
	print('Okie')
	CTFManager.ResetMap()
	
	wait(CTFSettings.CTFSettings)
end

This most likely won’t work if you just copy and paste it. You’re going to have to rewrite small adjustments to make it work.

@WinterGoons Yea, but I need it to be in there, and run before the CTFManager.ResetMap() runs. I had first planned on using it (and I’ve used it on other projects of the same kind and it works) like this

while true do

	repeat 
		local NUmPlayers = Plrs:GetPlayers()
		
		wait(CTFSettings.CheckInterval)
	until #NUmPlayers >= CTFSettings.MinimumPlayersRequired 
	
	CTFManager.Begin()
	local EndState = CTFEnd.Event:Wait()
	
	local EndStatus = CTFDisplayManager.GetEndStatus(EndState)
	print(EndStatus)
	
	print('Okie')
	CTFManager.ResetMap()
	
	wait(CTFSettings.CTFSettings)
end

But it was not working. So basically I need it there to prevent the CTFManager.ResetMap() from running beforehand.

Make something else other than putting it there to prevent it from resetting.