game.Players.PlayerRemoving:Connect(function(player)
player.CharacterRemoving:Connect(function(character)
for i, v in pairs(character:GetChildren()) do
if v:IsA("BoolValue") then
if game.ReplicatedStorage:FindFirstChild(v.Name) then
local UserId = "Player_"..player.UserId..v.Name
local data = {
Money = player.Money.Value;
Kunai = player.Kunai.Value;
}
local success, errormessage = pcall(function()
GameData:SetAsync(UserId, data)
end)
if success then
print("Data Saved Succesfully")
else
print("Data Did Not Save Correctly")
warn(errormessage)
end
end
end
end
end)
end)
COMMUNITY QUESTION
Why does the following code output nothing and not save the data?
2 answers
Try making data into a dictionary rather than an array. I don't think you can save arrays.
Is this already answered? You can't save tables. Look at my answer here: https://scriptinghelpers.org/questions/123765/why-isnt-this-data-store-saving-the-pcall-says-it-is-working
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
what if you delete "warn(errormessage)" ?
or delete end at line 25 cuz i don't see anything wrong with the datastore part of this script. and i don't think you can warn a pcall :v