Should I use ModuleScripts or Bindables to create this system?

I’m making a system to keep track of a player’s win value and handle some other stuff related to the wins value.

Functions:
GetPlayerWins()
SetPlayerWins()
UpdatePlayerRank() – // Updates the rank billboardGui above the player’s head according to amount of wins
SetPlayerRank() – // Sets player’s rank
IncreasePlayerWins() – // Increases win amount by specified increase number

Possible Methods:

Method 1:
Add these functions to a server script in ServerScriptService and use BindableEvents/BindableFunctions to call them from other scripts.

Method 2:
Add a ModuleScript in ReplicatedStorage and require it in other scripts to access these functions. May also use OOP.

Question:

Should I use Method 1 or Method 2 to create this system? Which is more practical/reliable? Which is better for performance? Which is better practice?

Any replys are much appreciated!

2 Likes

Personally I prefer to use module scripts. Whenever I use bindable events/functions, my explorer just gets really messy and cluttered quickly. And as you said there is the benefit of being expandable with oop

1 Like

Definitely prefer method 2, since bindables need to be defined at runtime, i’ve always feared the possibility of a race condition, where a script invokes a bindable function who’s .Invoke property hasn’t been defined yet.

1 Like

Personally i’d use method 2

Why?

  1. It will be easier to work with later in the future
  2. Its widely considered a great practice
  3. More Performant
1 Like

Using Bindables leads to undesirable behaviors that could pose an issue to some use cases, tables in particular are the issue.

No matter the source, if you pass a table through a Bindable :Fire()/:Invoke() method, that table is not the table you passed. It’s a deep copy of that table, as Bindables deep copy any tables sent through them.

To just avoid annoying edge case bugs I’d say just use a Module in this scenario.

Sorry this was drafted and I forgot to post it.

1 Like

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