Which is more efficient?

Imagine you have 3 modules, and you need the PlayerJoined event for tracking the character.
Would it be more efficient to have one Module with the player joined event, and have it fire to the other modules, or would it be more efficient to have the PlayerJoined event in each module? Or would there be no difference at all?

Example:

game:GetPlayers("Players").PlayerJoined:Connect(function(plr)
	-- Module 1 Code
	Module2:PlayerJoined(plr)
	Module3:PlayerJoined(plr)
end)

Could you give a little more details on your problem?

I’d probably say it depends on what you want, if you wanted Module 2 to run before module 3 then this is a good method, but if you don’t care when module 2 or 3 run, then you could do it on each module and that may make it slightly faster.

The way you have it currently written I’m pretty sure it’d run the module2 code fully the run module3 code.

Yes, threads in lua yield until a module returns a value.

1 Like

The issue isn’t which module runs first, it’s more that I don’t want to have 10000 scripts that have the same PlayerEvent function, just because I don’t want a ton of memory leaks. Would it be more efficient if I only had one of those events, and just moved the data over to the other modules, or would there be no difference?

Personally I just stick with just using one event when possible

1 Like