I am trying to make save and load, but I ran into one problem: SetAsync does not save, unless I set it manually. I have tried datastore plugins such as DataStoreX, but none have worked. Code:
local DataStoreService = game:GetService("DataStoreService") local dataStore = DataStoreService:GetDataStore("DAT") game.Players.PlayerAdded:Connect(function(player) local coins = Instance.new("IntValue") coins.Name = "coins" coins.Parent = player local playerUserId = "Player_"..player.UserId local success, err = pcall(function() coins.Value = dataStore:GetAsync(playerUserId) end) if success then print("Load success!") else warn(err) end print(player.coins.Value) end) game.Players.PlayerRemoving:Connect(function(player) local success, err = pcall(function() print(player.coins.Value) local playerUserId = "Player_"..player.UserId dataStore:SetAsync(playerUserId, player.coins.Value) end) if success then print("Save success!") else warn(err) end end) game:BindToClose(function() wait(5) end)
NOTE #1: I TRIED SAVING IN BOTH BINDTOCLOSE AND PLAYERREMOVING, BUT IT STILL DIDN'T SAVE. NOTE #2: I'M RUNNING INSIDE ROBLOX STUDIO
I tried it, and it didn't happen that it won't save. Try to restart the studio or restart the computer. Image: https://gyazo.com/4541af38180329af133b8f6e121eacbb