Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Are datastores limited to one value and do they need to be attached to player ID?

Asked by 4 years ago

Hi, I am coding my first game and I am wondering what is the best way to save data that is necessary during the game (but not necessary after the game is finished). In other words, I need to save the score and certain modifications that have have happened in local scripts in order to make them available to all clients. For example I want the score of all players to update in all local guy's and if a player joins a game late, I want some changes to be loaded in his playerAdded function. Are datastores good for this? They seem to be player specific, limited to one value attached always to the player ID and not to be game specific but player specific. Is there a better way to save and share data? thanks

0
Use data store 2, (search it up on the developer forum) MmadProgrammer 35 — 4y

1 answer

Log in to vote
0
Answered by
Syclya 224 Moderation Voter
4 years ago
Edited 4 years ago

A DataStore can store multiple values. Its limitations are shown here.

Saving data:

If you are looking to store data while the game is running; a interval that saves data every x minutes for every player in the server. You should also have a PlayerRemoving and a BindToClose event.

You can use GetAsync() to check if anything is stored for the player. If the key does not exist, it returns nil. This function caches for about 4 seconds.

(And no, it does not have to store the player's userid. But that is recommended as the player is able to change her/his name without losing their data.

Ad

Answer this question