Is something wrong with this datastore script?

local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("DSS")

	local Leaderstats ="Folder", Player)
	Leaderstats.Name = "leaderstats"
	local CashV="IntValue", Leaderstats)
	CashV.Name = "Cash"
	CashV.Value = 0
	local LevelV="IntValue", Leaderstats)
	LevelV.Name = "Level"
	LevelV.Value = 1
	local WinsV="IntValue", Leaderstats)
	WinsV.Name = "Wins"
	WinsV.Value = 0

	local Data = DataStore:GetAsync(Player.UserId)
	if Data then
		CashV.Value = Data.Cash
		LevelV.Value = Data.Level
		WinsV.Value = Data.Wins

	DataStore:SetAsync(Player.UserId, {
		["Cash"] = Player.leaderstats.Cash.Value;
		["Level"] = Player.leaderstats.Level.Value;
		["Wins"] = Player.leaderstats.Wins.Value;

Seems about right. If the code above doesn’t work, then:

  1. Enable HTTP and API requests in the studio settings, since those might prevent you from getting data directly in studio.
  2. Try playing the game outside of studio. Whenever you stop playtesting, your player leaves the local server and the server gets shutdown immediately as well.
1 Like