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

DataStore Not Saving anything no errors or stuff!?

Asked by 3 years ago

I am trying to save a table but is it is not saving, studio access to api is enabled and all. i might not be able to reach you tonight but thanks if you can help me:

Data = game:GetService("DataStoreService")
SaveData = Data:GetDataStore("PlayerSave1")
HasPlayed = Data:GetDataStore("PlayerHasPlayed")
DefaultSave = {0,0,0}

function LoadSave(plr)
    local id = tostring(plr.UserId)
    local mats = game.ReplicatedStorage.Materials
    local saveFile = nil
    saveFile = SaveData:GetAsync(id) or DefaultSave
    local PlayerFolder = Instance.new("Folder",mats)
    PlayerFolder.Name = plr.Name
    local Wood = Instance.new("NumberValue",PlayerFolder)
    Wood.Name = "Wood"
    Wood.Value = saveFile[0]
    local Stone = Instance.new("NumberValue",PlayerFolder)
    Stone.Name = "Stone"
    Stone.Value = saveFile[0]
    local Exp = Instance.new("NumberValue",PlayerFolder)
    Exp.Name = "Exp"
    Exp.Value = saveFile[0]
end

function Save(plr)
    local id = tostring(plr.UserId)

    local mats = game.ReplicatedStorage.Materials:WaitForChild(plr.Name)

    local success, err = pcall(function()
        SaveData:SetAsync(id,{mats.Wood.Value,mats.Stone.Value,mats.Exp.Value})
    end)

    if not success then
        warn(err)
    end
end

local players = game:GetService("Players")

players.PlayerAdded:Connect(LoadSave)
players.PlayerRemoving:Connect(Save)

also i do not get any errors i have been trying to work on this for 3 days help is much appreciated and just thanks for taking the time for reading this. doeschickens,

0
i have the same problem as well but if you havent already turn on api services brodywth 97 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

I Used DataStore2: here it worked amazing first try! i highly recommend you try it!

Ad

Answer this question