Hey, I’m learning datastorage and in my script none of my data is save, I’m also getting this error as well in my ouput.
Also in my pcall function it’s saying is successfully loaded and saved my data as well so I’m just a bit confused.
I feel like I’m doing something obviously wrong and if anyone knows the solution to my issue it would be great help.
local DataStorage = game:GetService("DataStoreService")
local DataCoinsSaveSlot = DataStorage:GetDataStore("DataCoinSaveSlot")
local function PlayerAddedFunction(Player)
local LeaderFolder = Instance.new("Folder", Player)
LeaderFolder.Name = "leaderstats"
local DataCoinValue = Instance.new("IntValue", LeaderFolder)
DataCoinValue.Name = "Coins"
local Success, Unsuccessful = pcall(function()
return DataCoinsSaveSlot:GetAsync(Player.UserId)
end)
if Success then
DataCoinValue.Value = DataCoinsSaveSlot
print("coins saved")
else
DataCoinValue.Value = 0
print("coins didn't load?")
end
end
game.Players.PlayerAdded:Connect(PlayerAddedFunction)
local function PlayerLeavingFunction(Player)
local Leaderstats = Player:WaitForChild("leaderstats")
local DataCoinValue = Leaderstats:WaitForChild("Coins")
local Success, Unsuccessful = pcall(function()
DataCoinsSaveSlot:SetAsync(Player.UserId, DataCoinValue.Value)
end)
if Success then
print("coins saved")
else
print("coins didn't save error")
end
end
game.Players.PlayerRemoving:Connect(PlayerLeavingFunction)
game:BindToClose(function()
wait(1)
end)