game.Players.PlayerRemoving:Connect(function(Player)
local SaveData = {}
for _,Child in pairs(Player.PlayerValues:GetChildren())do
table.insert(SaveData, Child.Value)
end
DataStore:SetAsync(Player.UserId, SaveData)
end)
script to load data
game.Players.PlayerAdded:Connect(function(Player)
local PlayerValues = Instance.new("Folder")
PlayerValues.Name = "PlayerValues"
PlayerValues.Parent = Player
local Country = Instance.new("StringValue")
Country.Name = "Country"
Country.Parent = Player:WaitForChild("PlayerValues")
local Language = Instance.new("StringValue")
Language.Name = "Language"
Language.Parent = Player:WaitForChild("PlayerValues")
local Graphics = Instance.new("StringValue")
Graphics.Name = "Graphics"
Graphics.Parent = Player:WaitForChild("PlayerValues")
local Mouse = Instance.new("StringValue")
Mouse.Name = "Mouse"
Mouse.Parent = Player:WaitForChild("PlayerValues")
local GetData = DataStore:GetAsync(Player.UserId)
if GetData then
Country.Value = GetData[1]
Language.Value = GetData[2]
Graphics.Value = GetData[3]
Mouse.Value = GetData[4]
print(GetData[1])
end
end)
basically its not saving any data nor is it erroring
game.Players.PlayerRemoving:Connect(function(Player)
local SaveData = {}
for i, Child in pairs(Player.PlayerValues:GetChildren())do
SaveData[Child.Name] = Child.Value
end
DataStore:SetAsync(Player.UserId, SaveData)
end)
loading
game.Players.PlayerAdded:Connect(function(Player)
local PlayerValues = Instance.new("Folder")
PlayerValues.Name = "PlayerValues"
PlayerValues.Parent = Player
local Country = Instance.new("StringValue")
Country.Name = "Country"
Country.Parent = PlayerValues
local Language = Instance.new("StringValue")
Language.Name = "Language"
Language.Parent = PlayerValues
local Graphics = Instance.new("StringValue")
Graphics.Name = "Graphics"
Graphics.Parent = PlayerValues
local Mouse = Instance.new("StringValue")
Mouse.Name = "Mouse"
Mouse.Parent = PlayerValues
local GetData = DataStore:GetAsync(Player.UserId)
if GetData then
for ValueName, Value in pairs(GetData) do
PlayerValues[ValueName].Value = Value
end
print(GetData)
end
end)
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("PlayerValues")
game.Players.PlayerRemoving:Connect(function(Player)
local SaveData = {}
for i, Child in pairs(Player.PlayerValues:GetChildren())do
SaveData[Child.Name] = Child.Value
end
DataStore:SetAsync(Player.UserId, SaveData)
end)
game.Players.PlayerAdded:Connect(function(Player)
local PlayerValues = Instance.new("Folder")
PlayerValues.Name = "PlayerValues"
PlayerValues.Parent = Player
local Country = Instance.new("StringValue")
Country.Name = "Country"
Country.Parent = PlayerValues
local Language = Instance.new("StringValue")
Language.Name = "Language"
Language.Parent = PlayerValues
local Graphics = Instance.new("StringValue")
Graphics.Name = "Graphics"
Graphics.Parent = PlayerValues
local Mouse = Instance.new("StringValue")
Mouse.Name = "Mouse"
Mouse.Parent = PlayerValues
local GetData = DataStore:GetAsync(Player.UserId)
if GetData then
for ValueName, Value in pairs(GetData) do
PlayerValues[ValueName].Value = Value
end
print(GetData)
end
end)