I'm particularly picky of how I write, manage and code my DataStores. Is it better to GetAsync() a DataStore everytime a player joins, or when the player has loaded and requests the server (obviously with security checks) to load their data?

I.e. Loading the datastore on playerjoin

local DataStoreService = game:GetService("DataStoreService")
local ds = DataStoreService:GetDataStore("ds")

game:GetService("Players").PlayerAdded:Connect(function(Player)
	ds:GetAsync(Player.UserId)
end)

Compared to..

Loading the datastore on client request

local DataStoreService = game:GetService("DataStoreService")
local ds = DataStoreService:GetDataStore("ds")

game:GetService("ReplicatedStorage").FetchData.OnServerEvent:Connect(function(Player)
	ds:GetAsync(Player.UserId)
end)
--Again, security checks to ensure this isn't abused

What's the better option?

1 comment

1

"Player joins" and "player loaded" are technically the same thing, right? I really don't see why you should use a remote event fired by the client to load data unless you have a save button which is controlled by a local script.