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

DataStore only saving 2 values?

Asked by
Donut792 216 Moderation Voter
5 years ago

my datastores not saving all of the values i have in it. heres 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)
0
which ones are saved. and which ones are not saved. 129Steve129 7 — 5y
0
^^^^ SmartNode 383 — 5y
0
Coins and Moral are the only ones saving Donut792 216 — 5y

Answer this question