How to edit a players data when they aren't in the server? (DataStore2)

I want to able to edit a players data if they aren’t in a server or even on another server.

Basically my idea is I want players to send messages to each other (not Roblox chat, custom messaging) And I know if MessagingService but I don’t think that will work fully how I want. Problem is if a player who you are sending to isn’t in the game, I don’t know what to do. I only know of how to edit Data of players who are within the game at that time. So how can I make changes to a players data when they are offline? I’m using DataStore2 btw. Is there any sort of function that can just return any users data and allow edits to be made?

How I am saving/Loading data

function DataManager.Load(player)
	local PlayerDataStore = DataStore2(DataName, player)
	local PlayerDataTable = PlayerDataStore:GetTable(DefaultData)
	local PlayerDataFolder = Converter.Convertr(PlayerDataTable) -- Convert to physical instances
	PlayerDataFolder.Name = 'PlayerData'
	PlayerDataFolder.Parent = player

function DataManager.Save(player)
	if player:FindFirstChild('PlayerData') then
		local PlayerDataStore = DataStore2(DataName, player)
		local PlayerDataTable = Converter.Convert(player.PlayerData)


DataStore2 does not have native support for accessing offline player data, it would require forking the module. If you want me to help you with that let me know with a reply.

Yes please :grimacing: or unless it’s best to use a completely seperate data store for this?

Does the thing you suggested not work? :confused:

Nope. I made a mistake so I am trying to see how to access offline player data. It is going to be very complicated though

Ah :confused:

I’m kinda just looking over my current data store setup, is how I’ve done it sufficient? I’m tryna follow tutorials on saving multiple keys and what not, which I don’t think I’m doing but all tutorials only show how to save 1 value, while mine has well over 20-30 values and tables to save across

Is it possible to do using normal data stores?

A sort-of hacky solution to your problem would be to retain messages to offline players in a general datastore. When the recipient joins the game, a datastore check would occur and would remove the message from the system and put it under the player. It’s sort-of hacky because if messages are sent to players who don’t ever play the game (ever or again), they would stay in the datastore forever and a build-up would result in you being forced to inevitably create more general datastores.

Since DataStore2 relies on the actual player objects, you cannot change the data directly within DataStore2 without modifying the module to accept userIds

You would need to figure out how DataStore2 stores its key values to the actual DataStore service (I presume it uses the player’s userId in some form). From there you can retrieve data by directly referencing the key to the real DataStore service.

Don’t use datastoe2, from personal testing with it I found it to be unreliable despite what others have said, besides normal datastoring works just fine with a simple function checking for the player incorrectly leaving.

How can I do it using normal data stores then?

I’m not after checking if a player left. I want to be able to edit there data while they aren’t even in a server

local dss = game:GetService("DataStoreService");

local data = dss:GetDataStore("main");

function editdata(playersid)
    local userdata = data:GetAsync(playersid); --// playersid is the userid of a player
    userdata.Coins = 1000 --// the edit
    data:SetAsync(playersid, userdata);

Quick example.