So I have this script here
local datastore = game:GetService("DataStoreService") local ds1 = datastore:GetDataStore("ds1") local ds2 = datastore:GetDataStore("ds2") game.Players.PlayerAdded:connect(function(plr) local folder = Instance.new("Folder", plr) folder.Name = "leaderstats" local fruits = Instance.new("IntValue", folder) fruits.Name = "Fruits" local coins = Instance.new("IntValue", folder) coins.Name = "Coins" fruits.Value = ds1:GetAsync(plr.UserId) ds1:SetAsync(plr.UserId, fruits.Value) coins.Value = ds2:GetAsync(plr.UserId) ds2:SetAsync(plr.UserId, coins.Value) if plr.leaderstats.Fruits.Value == 0 then warn("data not loaded") end if plr.leaderstats.Coins.Value == 0 then warn("data not loaded") end end) game.Players.PlayerRemoving:connect(function(plr) local fruits = plr.leaderstats.Fruits local coins = plr.leaderstats.Coins ds1:SetAsync(plr.UserId, fruits.Value) print("data saved") ds2:SetAsync(plr.UserId, coins.Value) print("data saved") end)
Whenever I disconnect output gives a message about the datastore being quethed, however that only happens whenever the int values are zero. I tried changing them with a script and manually with explorer but I cannot get it to save.