Would you check my script really fast for Data Persistence?
local debtKey = "PlayerDebt"
local cashKey = "PlayerCash"
local pageKey = "PlayerPages"
local bookKey = "PlayerBooks"
Players.PlayerAdded:connect(function(player)
if player:WaitForDataReady() then
--Create leaderboard
local ls = Instance.new("IntValue", player)
ls.Name = "leaderstats"
--Create stats
local debt = Instance.new("IntValue", ls)
debt.Name = "Net Dues"
debt.Value = player:LoadNumber(debtKey)
local cash = Instance.new("IntValue", ls)
cash.Name = "Money!"
cash.Name = player:LoadNumber(cashKey)
local pages = Instance.new("IntValue", ls)
pages.Name = "Pages read"
pages.Value = player:LoadNumber(pageKey)
local books = Instance.new("IntValue", ls)
books.Name = "Books checked out"
books.Value = player:LoadNumber(bookKey)
end
end)
Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(msg)
if msg == "/save" then
if player:FindFirstChild("leaderstats") then
player:SaveNumber(debtKey, player.leaderstats.debtKey.Value)
player:SaveNumber(cashKey, player.leaderstats.cashKey.Value)
player:SaveNumber(pageKey, player.leaderstats.pageKey.Value)
player:SaveNumber(bookKey, player.leaderstats.pageKey.Value)
end
end
end)
end)

1 comment
Why do I keep getting thumbed down? :/