I'm working on a save script that updates my datastore whenever an event is triggered by one of the various outside scripts. I'm just unsure of which way I should code the BindableEvents. Here are my options:
SaveAchievementEvent.Event:Connect(function(Key, UpdatedValue)
UserData.Achievements[Key] = UpdatedValue
AchieveData:SetAsync(UserData.Achievements)
end)
SaveCurrencyEvent.Event:Connect(function(Key, UpdatedValue)
UserData.Currency[Key] = UpdatedValue
CurrencyData:SetAsync(UserData.Currency)
end)
"etc..."
or should I combine them into one and just pass the values that I need from the scripts that are firing the event such as:
SaveEvent.Event:Connect(function(TopKey, BottomKey, UpdatedValue, StatData)
UserData[TopKey][BottomKey] = UpdatedValue
StatData:SetAsync(UserData[TopKey])
end)
I'm asking this for a couple of reasons. First, will it create some kind of bottleneck if I combine the Events into one (I'm worried if the event is passed too much data too quickly)? Second, anything else unforeseen that I'm unaware of?
*It's important to note that I'm using Datastore2, so simply passing a table isn't an option because I MUST use string keys (Datastore2 requires this, and the documentation of BindableEvents states that string keys aren't allowed to be passed)

2 comments
The keys are separate. Instead of having: UserData.Currency or UserData.Achievements I will pass the string value of "Currency" or "Achievements" from a different script to be applied to this universal save event.
Then I would seperate the events.