What are your coding patterns that are causing problems with Deferred events?
I’m kind of lost on why we can’t enable it live? Like we can subject ourselves to potentially uncompatible code on Studio like we wouldn’t wanna disable it over on Studio too? I’m all in for Deferred event behaviour but letting me just test it out on Studio but not live is just annoying. It’s one of the reasons my FastSignal library has an auto-detect mode for what the game is using, because of this difference in live and non-live games (ofc also for ease of use and swapability with older signal libraries based on bindableevents but like really?)
There was / there’s much more breaking properties on Workspace that work on live games, why isn’t that the case for deferred events behaviour?
I got an IPv6 shirt, will I have to get an deferred event shirt??
You can always change the ways you go about what’s currently breaking your code. ConnectOnce is a matter of just checking if it was disconnected or not. Also I’m relatively sure that Roblox added a :Once function a while ago, though I’m not sure if it’s actually enabled. As for if you’re using a certain signal library that’s breaking with Deferred behaviour, FastSignal (mine the right one) has full support.
Predictable code usually doesn’t break because of Deferred events and when it does, it’s minor and should be easy to change. It’s not that hard to migrate to Deferred event behaviour because whatever works on Deferred mostly works on Immediate, just not the other way around.
Well, actually, none that can’t be fixed in a few minutes.
That still doesn’t fully replace Immediate’s current behaviour, e.g. if you have a connection that will disconnect itself if a certain condition is met. Yes, you can make it work, but it will unnecessarily run the connection more times than it should be ran and it triggers my OCD honestly (putting performance impact aside as I bet that it’s negligible).
-- ScriptA
local scriptB = game.ServerStorage.ScriptB
local event = game.ServerStorage.ScriptB.BindableEvent
scriptB.Parent = game.ServerScriptService
event:Fire()
the problem is that this property is global meaning that it effects all events in the project
this can be a problem when creating public modules/libraries that will be used by other developers where you don’t have control over the SignalBehavior property and if you have time sensitive code this property can break your module
Mixing SignalBehaviour usually creates a lot of issues, as code that would otherwise run immediately is now running after some other code and it becomes way harder to migrate games to Deferred. If your game is using a custom signal library, switch to something like FastSignal that supports and adapts to whatever mode your game is using.
If your code works on Deferred, it will usually work on Immediate no issue. (except for some instances like when you build your own signal library but that’s not really what I’m talking about)
This is because the Fire is running before the connection, so when the fire happens, there is no connection therefore it doesn’t have anything to fire, this is a race condition, some internal code is definitely changing the order on which what script runs first, and I am aware that events that would fire on the server start end up running before any developer-made script is ran on Deferred, this is weird but my suggestion on any case is to deal with this race condition by having code that does with it, so with a check, for example, some people had issues where .PlayerAdded would connect only after the player joined at least on Studio, and so that player never had code handling their entrance, however the best practice is actually to deal with the current situation, when you :Connect you’re talking about when something in the future happens, so if you want it to happen to everything, you should always have code that also handles with the current situation, so in this case for example, you would do :GetPlayers and run the function on the found players so that you don’t have a risk of a potential race condition.
My module I created requires signals to spawn and not defer I had no choice but to create my own signal module so that whoever is using my module can freely change the SignalBehavior property and not break the module this works but ideally I would prefer to use Roblox’s blindableevents but at the current time is not a option
yer its a strange race condition, I guess internally the script is loading after a defer causing the fire to get called first but it feels correct that when I set the scripts parent the script should load instantly and should not be deferred
I would rather have a new method added called “ConnectDeferred” so we can use either method anytime we want making it flexible and fixing both problems with introducing deferred connections.
How are we expected to create self cleaning scripts using this event behavior? say I wanted to run some code to clean up any changes the script has done once it’s destroyed, any event that I tried like .Destroyed or .AncestryChanged never actually fired the callback since the script thread was terminated before the deferred event was processed
The point of this is for you to learn how to adapt to the deferred behaviour and apply it everywhere, since if you can half commit to it why not fully? Its supposed to be the least buggiest way of doing things from what I’ve read.
I tried enabling deferred event in my game, and as expected, some things broke.
However, I do see that even core scripts are getting errors. For example in the GameTranslator module in CoreScripts had an error with a connection variable set to nil. It looks like it happens when tools are destroyed when the character respawns.
When the signal behavior is set to Deferred, it stops the plugin.Unloading event from firing when a plugin is disabled, updated, or a place file is closing.
This prevents last-minute operations like cleaning up extra objects created by the plugin or saving plugin data.
To see this effect in action,
Make sure the SignalBehavior property of is set to Default or Immediate and that the Output widget is open ( tab > )
Create a new Script with the following code inside it,