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?
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
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.
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.