this is the code in question from the title. When i run the script i get the success message printed to console when the data is saved however, ive checked with a datastore editor and this isnt the case. Ive spent 3 days trying to get this to save stuff but it just doesnt
local DataStoreService = game:GetService("DataStoreService")
local gameDataStore = DataStoreService:GetDataStore("gameDataStore")
local Players = game:GetService("Players")
game.Players.PlayerAdded:Connect(function(player)
player = player
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local money = Instance.new("IntValue",leaderstats)
money.Name = "money"
money.Value = 10
local strength = Instance.new("IntValue",leaderstats)
strength.Name = "strength"
strength.Value = 0
local newplayer = Instance.new("IntValue", leaderstats)
newplayer.Name = "newplayer"
newplayer.Value = 1
-- load data
local success, errormessage = pcall(function()
dataDict = gameDataStore:GetAsync(player.UserId)
end)
if success then
player.leaderstats.money.Value = dataDict.moneydata
player.leaderstats.strength.Value = dataDict.strengthdata
player.leaderstats.newplayer.Value = dataDict.newplayerdata
print("loaded data")
else
print("big homosexual while getting data")
warn(errormessage)
end
end)
-- The part below this does the saving
local function gamesave(player)
print(player)
local UserId = player.UserId
local money = player.leaderstats.money.Value
local strength = player.leaderstats.strength.Value
local newplayer = player.leaderstats.newplayer.Value
local dataDict = {
moneydata = money,
strengthdata = strength,
newplayerdata = newplayer
}
local success, errormessage = pcall(function()
gameDataStore:SetAsync(UserId,dataDict)
end)
if success then
print("data saved")
else
print("data failed")
warn(errormessage)
end
end
game.Players.PlayerRemoving:Connect(function(player)
for i, player in pairs(Players:GetPlayers()) do
if i > 1 then
print(i)
gamesave(player)
end
end
end)
game:BindToClose(function()
for i, player in pairs(Players:GetPlayers()) do
if i == 1 then
print(i)
gamesave(player)
break
end
end
end)

2 comments
i should also mention that i get this message in console
Are you completely sure that it is not your loading script flawed?