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

Datastore only saving 2 out of 10 Values?

Asked by
Donut792 216 Moderation Voter
5 years ago

like the question says my datastore is only saving 2 out of the 10 given values this is the script:

local Data = game:GetService("DataStoreService"):GetDataStore("DataStore")
game.Players.PlayerAdded:Connect(function(plr)
    local Folder = Instance.new("Folder",plr)
    Folder.Name = "Nut"
    local Coins = Instance.new("IntValue",Folder)
    Coins.Name = "Coins"
    local Moral = Instance.new("IntValue",Folder)
    Moral.Name = "Moral"

    local Will = Instance.new("IntValue",Folder)
    Will.Name = "Will"
    local Skill = Instance.new("IntValue",Folder)
    Skill.Name = "Skill"
    local Strength = Instance.new("IntValue",Folder)
    Strength.Name = "Strength"
    local General = Instance.new("IntValue",Folder)
    General.Name = "General"

    local Five = Instance.new("BoolValue",Folder)
    Five.Name = "Five"
    local Ten = Instance.new("BoolValue",Folder)
    Ten.Name = "Ten"
    local Fifteen = Instance.new("BoolValue",Folder)
    Fifteen.Name = "Fifteen"
    local Twenty = Instance.new("BoolValue",Folder)
    Twenty.Name = "Twenty"


    local SavedItems = Data:GetAsync(plr.userId)
    if SavedItems then
        Coins.Value = SavedItems.Coins or 0
        Moral.Value = SavedItems.Moral or 0
        Will.Value = SavedItems.Will or 0
        Skill.Value = SavedItems.Skill or 0
        Strength.Value = SavedItems.Strength or 0
        General.Value = SavedItems.General or 0
        Five.Value = SavedItems.Five or false
        Ten.Value = SavedItems.Ten or false
        Fifteen.Value = SavedItems.Fifteen or false
        Twenty.Value = SavedItems.Twenty or false
    else
        Coins.Value = 0
        Moral.Value = 0
        Will.Value = 0
        Skill.Value = 0
        Strength.Value = 0
        General.Value = 0
        Five.Value = false
        Ten.Value = false
        Fifteen.Value = false
        Twenty.Value = false
    end
end)

game.Players.PlayerRemoving:Connect(function(plr)
    local Saving = {["Coins"] = (plr.Nut).Coins.Value;
        ["Moral"] = (plr.Nut).Moral.Value;
        ["Will"] = (plr.Nut).Will.Value;
        ["Skill"] = (plr.Nut).Skill.Value;
        ["Strength"] = (plr.Nut).Strength.Value;
        ["General"] = (plr.Nut).General.Value;
        ["Five"] = (plr.Nut).Five.Value;
        ["Ten"] = (plr.Nut).Ten.Value;
        ["Fifteen"] = (plr.Nut).Fifteen.Value;
        ["Twenty"] = (plr.Nut).Twenty.Value;}
    Data:SetAsync(plr.userId, Saving)
end)

game:BindToClose(function()

    for i, player in pairs(game.Players:GetPlayers()) do
    if player then
        player:Kick("Last Player Shutdown")
        end
    end
    wait(5)
end)

the only 2 values saving are Coins and Moral before i had will,skill,general, and strength in one folder and five,ten,fifteen and twenty in another folder all folders parented to the player but idk if that matters

Answer this question