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

saving inventory not saving ?

Asked by 9 years ago

suppose to save everything in the inventory, and leaderboard stats.. it doesnt save anything..

function load(player)
    if player.DataReady then 
        if player then
            wait()
            local score = player.Folder:GetChildren()
            for i = 1,#score do

                    local ScoreLoaded = player:LoadNumber(score[i].Name)
                    wait()
                    if ScoreLoaded ~= 0 then
                        score[i].Value = ScoreLoaded
                    else

                    end
                end

            ----Load Inventory----
            local inventory = player:findFirstChild("Inventory")
            if inventory then
                local saved_inv = player:LoadInstance("Invent")
                if saved_inv then
                    for j,k in pairs(saved_inv:GetChildren()) do
                        k.Parent = inventory
                    end
                end
            end
            end
    end
    end
function onPlayerEntered(player)
    local Inventory = Instance.new("Folder")
    Inventory.Name = "Inventory"
    Inventory.Parent = player

    local leaderboard = Instance.new("Folder")
    leaderboard.Name = "Folder"
    leaderboard.Parent = player

    local Beli = Instance.new("IntValue")
    Beli.Value = 10
    Beli.Name = "Beli"
    Beli.Parent = leaderboard

    local Trys = Instance.new("IntValue")
    Trys.Value = 2
    Trys.Name = "Trys"
    Trys.Parent = leaderboard

    local DF = Instance.new("StringValue")
    DF.Name = "DF"
    DF.Parent = leaderboard

    local GotDF = Instance.new("IntValue")
    GotDF.Value = 0
    GotDF.Name = "GotDF"
    GotDF.Parent = leaderboard

    local SetDF = Instance.new("IntValue")
    SetDF.Value = 0
    SetDF.Name = "SetDF"
    SetDF.Parent = leaderboard

    local Scene = Instance.new("IntValue")
    Scene.Value = 1
    Scene.Name = "Scene"
    Scene.Parent = leaderboard



    player:WaitForDataReady()
    load(player)
    wait()
end

function onPlayerLeaving(player)
end

game.Players.PlayerAdded:connect(onPlayerEntered)
game.Players.PlayerRemoving:connect(onPlayerLeaving)

0
I dont think that DataReady is a property of "Player" BSIncorporated 640 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Try using this line in localscript:

game.Players.LocalPlayer:SaveNumber(string Key, number Value)

Or to load:

game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer:LoadNumber(string Key)

0
"Server-side only Data persistance methods cannot be called from within a LocalScript. You'll need to process the saving in a Script." http://wiki.roblox.com/index.php?title=Data_persistence#Restrictions M39a9am3R 3210 — 9y
Ad

Answer this question