Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

BindableEvents not firing?

Hi,

I've found global functions (_G) to be generally unreliable in the past, so I figured I would use BindableEvents this time, and so far it's been much more organized.

However, for some reason, whenever I call my event to start the game process, it fails. No error message, and the rest of the code executes; it feels like it just skips the lines that fire the events.

Here's the snippet of code. I left out a ton of stuff in the function, but it shouldn't be important past knowing that it's running while the events are not.

EDIT: Also, the event IS being :connect'd in another snippet of code. I'll post it under this one.

function runGame()
	
	if #game.Players:GetChildren() < minPlayers.Value then
		return false
	end
	
	events.StartGame:Fire()
	inGame.Value = true
	currentTime.Value = gameTime.Value -- reset time
	
	-- code here that waits like 10 seconds, basically just consider this line a wait(10)

	events.EndGame:Fire()
	plagueActive.Value = false
	inGame.Value = false

end

Here's the connecting code:

local events = game.ServerStorage.Events
local testTable = {"Yes","No","Maybe so"}
local minPlayers = game.ServerStorage.ReadValues.MinPlayers.Value

script.Parent.Event:connect(function()
	print("Start game event fired.")
	events.LobbyToggle:Fire(false)
	events.KillAllPlayers:Fire()
end)

Thanks, all replies are appreciated!

3 comments

0
  1. Are you sure that these lines are being run? (Have you printed nearby the :Fire()s to make sure that's happening? 2) What about the code that's listening? Are you sure that's right? Are you sure its connection is actually running?
0

I edited the original post, read the bold words.

0

(As BlueTaslem suggests), Try adding a print statement before and after line 13 (in the first script) to make sure that the code you omitted is working correctly.

1 answer

Did you add the connect argument for the event?

function onEvent()
	--event
	print('Hallo')
end
 
local event = Instance.new("BindableEvent")
event.Parent = Workspace
 
event.Event:connect(onEvent)
 
event:Fire()

1 comment

0

I edited the original post, read the bold words.

This discussion is preserved as it was. New answers, comments, and votes are closed.