Ok so, I'm making a game, obviously, and ignore all the other values, except for Used1 or "Savevalue5", I know this script works because it works on everything except for the BoolValue Here is my script

local DS = game:GetService("DataStoreService"):GetDataStore("SaveMyData")
game.Players.PlayerAdded:Connect(function(plr)
    wait()
    local plrkey = "id_"..plr.userId
    local savevalue = plr.leaderstats.Points
    local savevalue2 = plr.leaderstats.Prestige
    local savevalue3 = plr.Code
    local savevalue4 = plr.leaderstats.Tokens
    local savevalue5 = plr.Used1


    local GetSaved = DS:GetAsync(plrkey)
    if GetSaved then
        savevalue.Value = GetSaved[1]
        savevalue2.Value = GetSaved[2]
        savevalue3.Value = GetSaved[3]
        savevalue4.Value = GetSaved[4]
        savevalue5.Value = GetSaved[5]

    else
        local NumbersForSaving = {savevalue.Value, savevalue2.Value, savevalue3.Value, savevalue4.Value, savevalue5.Value}
        DS:GetAsync(plrkey, NumbersForSaving)
    end
end)

game.Players.PlayerRemoving:Connect(function(plr)
    DS:SetAsync("id_"..plr.userId, {plr.leaderstats.Points.Value, plr.leaderstats.Prestige.Value, plr.Code.Value, plr.leaderstats.Tokens.Value, plr.Used1.Value})
end)

3 comments

0

Wouldnt it be easier to save them all to one datastore while using a table?

0

idk please just put a script i hate saying that but i'm not good at this

0

i don't really use datastores