Hey, I've been messing around with DataStore recently and for some reason when i was testing it, it wouldn't save. I did some investigating and the loading was fine, it just wouldn't save. There are no error messages, I've tried this in the game and in studio, i do have studio API enabled.
local DataStoreService = game:GetService("DataStoreService")
local TestStore = DataStoreService:GetDataStore("TestStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local TestVariable = Instance.new("IntValue", leaderstats)
TestVariable.Name = "Test"
TestVariable.Value = TestStore:GetAsync(player.UserId)
end)
game.Players.PlayerRemoving:Connect(function(player)
TestStore:SetAsync(player.UserId,player.leaderstats.Test.Value)
end)

3 comments
That is really strange. Still not getting anything. I've tried adding pcalls and bindtoclose but still nothing. Any ideas?
Are you using this is inside a serverscript instead of a localscript?
yes it is in a server script