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

How do i save more then value with datastore?

Asked by 6 years ago
local DSService = game:GetService('DataStoreService'):GetDataStore('lolidk6969219')
game.Players.PlayerAdded:connect(function(plr)
    local uniquekey = 'id'..plr.userId
    local stuff = Instance.new("Folder", plr)
    stuff.Name = 'stuff'
    local Invun = Instance.new('IntValue', stuff)
    Invun.Name = 'Stat1'
    Invun.Value = 1
    local str = Instance.new('IntValue', stuff)  --2nd thing i wanna save
    str.Name = 'Stat2'
    str.Value = 1



    local GetSaved = DSService:GetAsync(uniquekey)
    if GetSaved then
        Invun.Value = GetSaved[1]  --i tried adding the 2nd thing here
    else
        local NumbersForSaving = {Invun.Value}  --here
        DSService:SetAsync(uniquekey, NumbersForSaving)

    end
end)

game.Players.PlayerRemoving:connect(function(plr)
    local uniquekey = 'id'..plr.userId
    local Savetable = {plr.stuff.Stat1.Value} --and in here but it just seems to have the same value as invun?
    DSService:SetAsync(uniquekey, Savetable)



end)

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago

Watch this video I made on how to save more than one values in a datastore. Also pls subscribe to my channel

https://m.youtube.com/watch?v=zY53itnBchE

Another way of saving multiple values is to save the values in different datastores.

Ad

Answer this question