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

The datastore isn't being saved? [closed]

Asked by 7 years ago

nothing saves

datastore = game:GetService("DataStoreService"):GetDataStore("EmotionCity1")

function joined(plr)
    if plr:WaitForDataReady() then
        local key = "emotion-".. plr.userId
        local savedvalues = datastore:GetAsync(key)

        if savedvalues then
            plr.PlayerGui.GuiStuff.CurrentMoney.Money.Value = savedvalues[1]
            plr.PlayerGui.ChooseGender.Gender.Value = savedvalues[2]
            plr.PlayerGui.GuiStuff.Clothing.Slot1.OutfitName.Value = savedvalues[3]
            plr.PlayerGui.GuiStuff.Clothing.Slot2.OutfitName.Value = savedvalues[4]
            plr.PlayerGui.GuiStuff.Clothing.Slot3.OutfitName.Value = savedvalues[5]
            plr.PlayerGui.GuiStuff.Clothing.Slot4.OutfitName.Value = savedvalues[6]
            plr.PlayerGui.GuiStuff.Hats.Slot1.AccessoryName.Value = savedvalues[7]
            plr.PlayerGui.GuiStuff.Hats.Slot2.AccessoryName.Value = savedvalues[8]
            plr.PlayerGui.GuiStuff.Hats.Slot3.AccessoryName.Value = savedvalues[9]
            plr.PlayerGui.GuiStuff.Hats.Slot4.AccessoryName.Value = savedvalues[10]
        else
            local valuestosave = {plr.PlayerGui.GuiStuff.CurrentMoney.Money.Value, 
                                  plr.PlayerGui.ChooseGender.Gender.Value,
                                  plr.PlayerGui.GuiStuff.Clothing.Slot1.OutfitName.Value,
                                  plr.PlayerGui.GuiStuff.Clothing.Slot2.OutfitName.Value,
                                  plr.PlayerGui.GuiStuff.Clothing.Slot3.OutfitName.Value,
                                  plr.PlayerGui.GuiStuff.Clothing.Slot4.OutfitName.Value,
                                  plr.PlayerGui.GuiStuff.Hats.Slot1.AccessoryName.Value,
                                  plr.PlayerGui.GuiStuff.Hats.Slot2.AccessoryName.Value,
                                  plr.PlayerGui.GuiStuff.Hats.Slot3.AccessoryName.Value,
                                  plr.PlayerGui.GuiStuff.Hats.Slot4.AccessoryName.Value}

            datastore:SetAsync(key, valuestosave)
        end
    end
end
game.Players.PlayerAdded:connect(joined)

function left(plr)
    if plr:WaitForDataReady() then
        local key = "emotion-".. plr.userId

        local savedvalues = datastore:GetAsync(key)

        local valuestosave = {plr.PlayerGui.GuiStuff.CurrentMoney.Money.Value, 
                              plr.PlayerGui.ChooseGender.Gender.Value,
                              plr.PlayerGui.GuiStuff.Clothes.Slot1.OutfitName.Value,
                              plr.PlayerGui.GuiStuff.Clothes.Slot2.OutfitName.Value,
                              plr.PlayerGui.GuiStuff.Clothes.Slot3.OutfitName.Value,
                              plr.PlayerGui.GuiStuff.Clothes.Slot4.OutfitName.Value,
                              plr.PlayerGui.GuiStuff.Hats.Slot1.AccessoryName.Value,
                              plr.PlayerGui.GuiStuff.Hats.Slot2.AccessoryName.Value,
                              plr.PlayerGui.GuiStuff.Hats.Slot3.AccessoryName.Value,
                              plr.PlayerGui.GuiStuff.Hats.Slot4.AccessoryName.Value}

        datastore:SetAsync(key, valuestosave)

    end
end
game.Players.PlayerRemoving:connect(left)
0
Please provide errors and elaborate on the problem. You have supplied 58 lines of code and "nothing saves" as context. Goulstem 8144 — 7y
0
Hard to work with. +1 to omit moderation rep loss Goulstem 8144 — 7y

Closed as Too Broad by Goulstem

This question has been closed because it is too broad and is generally unanswerable. Please ask a more specific question.

Why was this question closed?