roblox-datastores
Reference for Roblox DataStoreService — saving, loading, and managing player data on the server.
Quick Reference
Basic Setup
Loading Data (GetAsync + pcall)
Always wrap datastore calls in pcall. They can fail due to network issues or rate limits.
Saving Data (SetAsync vs UpdateAsync)
Use SetAsync for simple overwrites. Use UpdateAsync when the value must be based on the current stored value (e.g., incrementing a counter safely across servers).
Retry Logic
Auto-Save: PlayerRemoving + BindToClose
Server shutdown without BindToClose silently discards unsaved data.
Ordered DataStores (Leaderboards)
Values must be positive integers.
Data Versioning / Migration
Include a _version field and migrate in the load path.
Use a versioned datastore name (PlayerData_v2) for breaking schema changes.


