I'm making a tycoon and currently in the process of developing a save system. I've run into many problems and fixed most, but there's one I can't quite get past. The save function doesn't seem to work, and I have no idea why. There are no errors in the output and I've tried using print() to debug, but none of that has worked.
Here's my code, if you spot anything that may need to be fixed, any and all help is appreciated!
function saveTycoon(plr)
local tycoon = plr:WaitForChild('PlayerValues').OwnsTycoon.Value --Finds the player's tycoon
local purchased = tycoon:WaitForChild('PurchasedObjects') --Finds the PurchasedObjects folder inside the player's tycoon
local tbl1 = {} --The table in which the purchased objects' names will be stored
for _, v in pairs(purchased:GetChildren()) do --Stores the names of purchased objects into table
table.insert(tbl1, v.Name)
end
local succ, err = pcall(function()
store:SetAsync(plr.UserId..'-cash', plr.leaderstats.Cash.Value) --Sets the player's cash value to a DataStore
end)
local succ2, err2 = pcall(function() --Sets the player's purchased objects table to a DataStore
store:SetAsync(plr.UserId..'-tycoon', tbl1) --This data doesn't save, but it doesn't display any errors from below if statement
end)
if succ then
print('Saved Cash Data.')
else
print('Failed To Save Cash Data.')
warn(err)
end
if succ2 then
print('Saved Tycoon Data.')
else
print('Failed To Save Tycoon Data.')
warn(err2)
end
end
Edit: Forgot to show which line the data wouldn't save

2 comments
The error might be at the load script
Good point, I'll post another question on with the load script