Help with DataStore Editor plugin

Hi, does anyone know how I can connect to datastore editor? I don’t understand what the name and scope are in my code.

script:

local DataStore = game:GetService("DataStoreService")
local PlayerData = DataStore:GetDataStore("playerGold")

game.Players.PlayerAdded:Connect(function(player)

	local playerFolder = Instance.new("Folder", player)
	playerFolder.Name = "Data"

	local Gold = Instance.new("IntValue", playerFolder)
	Gold.Name = "Gold"
	
	-- Load data
	local data
	local key = "Player_".. player.UserId
	local success, errormessage = pcall(function()
		data = DataStore:GetAsync(key)
	end)

	if success then
		Gold.Value = data
	elseif data == nil then
		Gold.Value = 0
		print("gold has been saved.")
	else
		print("error saving data, error saving data!!!")
		warn(errormessage)
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	local key = "Player_".. player.UserId

	local data = player.playerFolder.Gold.Value

	DataStore:SetAsync(key, data)
end)

The name is the name of your datastore (playerGold)
You are not using any scope, so leave it empty.

i just did and it still empty
image
image

Because you need the key.

image

To access your data, use Player_*YourUserID*

Like this?
local key = "Player_".. player.MatiasHarders
or am i wrong?

Your key is exactly: Player_1739689185
You are concatenating “Player_” with the player UserId.

local key = “Player_1739689185” like this? :scream:

I’m a bit confused, type this in the key section:

This gives me an error

image

Oh, got it. You can leave your code how it is. In the plugin key section, type the key Player_1739689185

image

Here where you put “test”

1 Like

and in the script and the datastore name what should I put? :scream: :frowning:

This part is correct:

image

Because you are using this datastore.


image

Here where you put “test”, it should be Player_1739689185

DO NOT CHANGE YOUR CODE, LEAVE IT AS IT WAS.

1 Like

Got this, but how can I access to this? gold int value

local Gold = Instance.new ("IntValue", playerFolder)
Gold.Name = "Gold"

image

This 0 should be your gold.

I changed it to 150 in datastore plugin and in the game print it is still 0

and i create a new instance to test if it really was the gold and this is not the gold

I can’t understand, you should put Player_1739689185 here:

image

Oh sorry about that im using the id of my other account

i did it and it show no data

Have you played the game with that account?

yes and still show no data :frowning: