My datastore dosen't work

I’ve already did my own version of your datastore

I could not find a better way to refer to money.value


local MyDataStore = DataStoreService:GetDataStore("MyDataStore")




game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local Money = Instance.new("IntValue")
	Money.Name = "Money"
	Money.Parent = leaderstats
	local Level = Instance.new("IntValue")
	Level.Name = "Level"
	Level.Parent = leaderstats
	
	local data
	local success, errormessage = pcall(function()
	data = MyDataStore:GetAsync(player.UserId.."-Money","Level")
	end)
	if success then
		Money.Value = data
		Level.Value = data
	else 
		print("Data Has Failed")
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	
	local success, errormessage pcall(function()
		MyDataStore:SetAsync(player.UserId.."-Money","Level",player.leaderstats.Cash.Value)
	end)
	if success then
		print("Data Has Passed")
	else
		print("Data Has Failed")
		warn(errormessage)
	end
end)

Pass it to an outside function.

Your datastore that you’ve made seems more complex and was confusing too read so I’d just made my own version of your datastore

Keep in mind this is a regular datastore and it’s not datastore 2

GetDataStore is not a valid member of GlobalDataStore

Alright Imma fix that real quick

Okay

local GameData = DataStoreService:GetDataStore("GameData")

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local Money = Instance.new("IntValue")
	Money.Name = "Money"
	Money.Parent = leaderstats
	
	local Level = Instance.new("IntValue")
	Level.Name = "Level"
	Level.Parent = leaderstats
	local data
	local success,errormessage = pcall(function()
		data = GameData:GetAsync(player.UserId.."-Money","-Level")
	end)
	if success then
		Money.Value = data
		Level.Value = data
		print("Success")
	else
		print("Failed")
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	local success,errormessage = pcall(function()
		GameData:SetAsync(player.UserId.."-Money","-Level",player.leaderstats.Money.Value.Level.Value)
	end)
	if success then
		print("Data Has Synced")
	else
		print("Data Has Failed")
	end
end)

Still not working

Are you doing it in Roblox Studio or in the game?

Roblox Studio - why? …

Then I’m probably making a mistake in the datastore give me a sec

Do you have API Services turned on?

Yes …

Join my game cause it seems like its working for me

I joined but how can i change my values so i can see if it works

Sorry you can’t I only have access too Dev Console commands