Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Check my script?

Asked by 9 years ago

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)
0
Why do I keep getting thumbed down? :/ AwsomeDanKid 0 — 9y

Answer this question