I recently went back to a quite old project, and noticed that the leaderstats scripts do save data at all anymore. The pcalls have also stoped saying anything at all, both at leave and join. Could anyone help me find what is wrong with this script? All help greatly appreciated!
local DSS = game:GetService("DataStoreService")
local myDataStore = DSS:GetDataStore("TopSecretSnails")
game.Players.PlayerAdded:Connect(function(plr)
local lead = Instance.new("Folder")
lead.Name = "leaderstats"
lead.Parent = plr
local Cash = Instance.new("IntValue")
Cash.Name = "Snails"
Cash.Parent = lead
local data
local succ, err = pcall(function()
data = myDataStore:GetAsync(plr.UserId.."_snails", plr.leaderstats.Snails.Value)
end)
if succ then
Cash.Value = data
--set the data equal to the current cash
print("Succesfully got the data!")
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local data = plr.leaderstats.Snails.Value
local succ, err = pcall(function()
myDataStore:SetAsync(plr.UserId.."_snails", plr.leaderstats.Snails.Value)
end)
if succ then
print("Succesfully saved coins")
else
print("Couldn't save coin data")
warn(err)
end
end)