Help with DataStore Editor Plugin

I recently downloaded the DataStore Editor v3 (DataStore Editor - Roblox) I’m inexperienced at datastores and too small brain to understand the tutorial. Anyway, I’m having some issues using the plugin. Here’s part of my datastore code for context.

local serverStorage = game:GetService("ServerStorage")
local datastore = game:GetService("DataStoreService"):GetDataStore("PlayerSave")
game.Players.PlayerAdded:Connect(function(player)

-- Code

local syrupData,sacrficeData,moneyData,multData,expiredData,frozenData,spicyData,mapleData,goldData
	
	local sucess,errormessage = pcall(function()
	syrupData = datastore:GetAsync("syrup"..player.UserId)
	sacrficeData = datastore:GetAsync("sacrfices"..player.UserId)
	moneyData =  datastore:GetAsync("money"..player.UserId)
		multData =  datastore:GetAsync("mult"..player.UserId)
		expiredData = datastore:GetAsync("expired"..player.UserId)
		frozenData = datastore:GetAsync("frozen"..player.UserId)
		spicyData = datastore:GetAsync("spicy"..player.UserId)
		mapleData = datastore:GetAsync("maple"..player.UserId)
		goldData = datastore:GetAsync("gold"..player.UserId)
	end)
	if sucess then
		if syrupData then
			syrup.Value = syrupData
			sacrifices.Value = sacrficeData
			money.Value = moneyData
			mult.Value = multData
		end
	end
end)
game.Players.PlayerRemoving:Connect(function(player)
	local sucess,errormessage = pcall(function()
		datastore:SetAsync("syrup"..player.UserId,player.leaderstats.Syrup.Value)
		datastore:SetAsync("sacrfices"..player.UserId,player.leaderstats.Sacrfices.Value)
		datastore:SetAsync("money"..player.UserId,player.leaderstats.Money.Value)
		datastore:SetAsync("mult"..player.UserId,player.leaderstats.Multiplier .Value)
		datastore:SetAsync("expired"..player.UserId,player.leaderstats.Bought.Value)
		datastore:SetAsync("frozen"..player.UserId,player.leaderstats.Bought.Value)
		datastore:SetAsync("spicy"..player.UserId,player.leaderstats.Bought.Value)
		datastore:SetAsync("maple"..player.UserId,player.leaderstats.Bought.Value)
		datastore:SetAsync("gold"..player.UserId,player.leaderstats.Bought.Value)
	end)
end)

For the name I put PlayerSave and I put one of the data variables for key(ex: syrupData, spicyData, etc.). When I do this it just says “No Data”. Thanks for any help.

Did you literally put syrupData or did you include the UserId? In your code, you’re appending the UserId. So for you, a key might be syrup1988663722.

Another issue that could be happening is that you’re only saving data when the player leaves. However, this could be problematic. Saving data takes a little bit of time. But if you’re the last player in the game, the server will shut down before the data has a chance to save. While you should still save when the player leaves, you should also save when the game closes down. You can do this using game:BindToClose, which you give a function, and the game will not close down until the function completes (kinda).

1 Like

On top of what @sleitnick said, I don’t recommend you use GetAsync like that. Instead, save all of it in one table. For example:

local data = {
    syrup = player.leaderstats.Syrup.Value,
    sacrfices = player.leaderstats.Sacrfices.Value
    --the list can go on
}
datastore:SetAsync(player.UserId, data)
3 Likes