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

Data Save Help?

Asked by 9 years ago

So its not saving this stuff and I need some help fixing it. If someone could please fix this I would jump in joy :)

local DSS = game:GetService('DataStoreService'):GetDataStore('Credits')
local Sp = game:GetService('DataStoreService'):GetDataStore('Speed')
function save(plr, value)
    DSS:UpdateAsync(plr.userId, function(Data)
        Sp:UpdateAsync(plr.userId, function(Datas)
            return value
        end)
    end)
end
function loads(plr)
    return Sp:GetAsync(plr.userId) or Sp:SetAsync(plr.userId, 0) and 0
end

function load(plr)
    return DSS:GetAsync(plr.userId) or DSS:SetAsync(plr.userId, 0) and 0
end

game.Players.PlayerAdded:connect(function(plr)
    local points = Instance.new('IntValue', plr)
    points.Name = 'Credits'
    points.Value = load(plr)
    local speed = Instance.new('IntValue', plr)
    speed.Name = "Speed"
    speed.Value = loads(plr)
    plr.PlayerGui.Menu.Credits.Text = "Credits: "..plr:FindFirstChild("Credits").Value
    points.Changed:connect(function()
        plr.PlayerGui.Menu.Credits.Text = "Credits: "..plr:FindFirstChild("Credits").Value
    end)
end)

game.Players.PlayerRemoving:connect(function(plr)
    save(plr, plr.Credits.Value)
    save(plr, plr.Speed.Value)
end)

1 answer

Log in to vote
0
Answered by 9 years ago

Please take a look at this page on how to post good questions. It helps a lot if you would edit your question accordingly.

I am really missing an explanation. Your code seems to have a few logic problems, which can only be solved if we can fully understand what your are trying to achieve.

Ad

Answer this question