I made a Folder that has another folder that has IntValues. When I go in-game and change one of my values and I leave the game it will not save the value! Please help!
local Data = game:GetService("DataStoreService"):GetDataStore("Stats")
game.Players.PlayerAdded:connect(function(player)
local Key = "Player-"..player.userId
local PlayerFolder = Instance.new("Folder", player)
PlayerFolder.Name = "PlayerFolder"
local StatFolder = Instance.new("Folder", PlayerFolder)
StatFolder.Name = "Stats"
local Strength = Instance.new("IntValue", StatFolder)
Strength.Name = "Strength"
local Defense = Instance.new("IntValue", StatFolder)
Defense.Name = "Defense"
local Sword = Instance.new("IntValue", StatFolder)
Sword.Name = "Sword"
local Data1 = Data:GetAsync(Key)
if Data1 then
PlayerFolder = Data1[1]
StatFolder = Data1[2]
Strength.Value = Data1[3]
Defense.Value = Data1[4]
Sword.Value = Data1[5]
else
local ThingsToSave = {PlayerFolder,StatFolder,Strength.Value,Defense.Value,Sword.Value}
local GiveData = Data:GetAsync(ThingsToSave,Key)
end
end)
game.Players.PlayerRemoving:connect(function(player)
local Key = "Player-"..player.userId
local Save = {player.PlayerFolder.Stats.Sword.Value,player.PlayerFolder.Stats.Defense.Value,player.PlayerFolder.Stats.Strength.Value}
local SaveData = Data:SetAsync(Save, Key)
end)

4 comments
You're assigning a Folder Object to Data1[1]? That really doesn't make sense.
Updated. Please make sure your title is relevant to the question, we do not need a question written in all caps.
We save data with the key first then the data not data then key.
You should also be saving data one line 26.