Bindable Event not Receiving Event

Bindable Event Firing Script:

if IsArcane.Value == true then

	local Chance = ArcaneModule.ThriveChance()
	print(tostring(Chance))

	if Chance == 1 then
		local RandomWait = math.random(12, 23)
		
		BreakLightsEvent:Fire()
		print("Fired Break Lights Event!")

		wait(RandomWait)

		if IsArcane.Value == true then
			print("Spawned: 'Thrive'")
			ActivateThrive()
		end
	else

	end
end

(^^ works perfectly fine)
Bindable Event Receiving Script:

BreakLightsEvent.Event:Connect(function()
	print("Got Break Light Event")
	local RandomWait = math.random(3, 7)

	wait(RandomWait)

	LightPart.BrickColor = BrickColor.new("Black")
	LightPart.Material = Enum.Material.Plastic
	LightPart.Light.Enabled = false
	LightBreakSound:Play()
	Spark.Enabled = true
	SparkSound:Play()
	print("Broke Light")

	wait(0.35)

	Spark.Enabled = false

end)

I don’t know what is going on, I’ve tried many different solutions, and none seem to work.

Any help is appreciated!

So I am assuming “Fired Break Lights Event!” prints then nothing? but you expect “Got Break Light Event” to print as well.

If the first script happens before the connection is made that would prevent it, is the first script part of a function or runs immediately? does the second script run immediately? try adding a print above the connection too.

print("Connecting BreakLightsEvent!")
BreakLightsEvent.Event:Connect(function()
	print("Got Break Light Event")
	local RandomWait = math.random(3, 7)
1 Like

Fired Break Lights Event! Prints, the Got Break Light Event does not.

I have no clue why :confused:

(there are also no errors inside of output…)

There’s most likely a race condition here. Please make sure the event is connected before firing it.

2 Likes

How do I check if the event is connected?

When connecting an event, an RBXScriptConnection is returned which has a Connected boolean.

1 Like

It’s not, the event doesn’t even receive the Fire function.

Sorry for the late response, but they are two seperate scripts. They are both in the same model, inside workspace.

Scripts can be run in any order roblox determines, they will not be run at the same time nor is it guaranteed to be the same order every time.

Could you try running with this print statement added right before the connection and post the output?

print("Connecting BreakLightsEvent!")
BreakLightsEvent.Event:Connect(function()
	print("Got Break Light Event")
	local RandomWait = math.random(3, 7)
1 Like

I just managed for it to work, I needed to add a wait() :confused:

Thank you to you andmaddjames28 for helping me though!

This is what a race condition is. You should try to put all of your code in one script so it’s guaranteed that it runs at the same time.

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