I want to save a table into my datastore then when I join back it prints the first value of the saved table
I get a warning on my output, the data doesn’t save when I leave
--Services
local Players = game:GetService("Players")
local dss = game:GetService("DataStoreService")
--Variables
local playerData = dss:GetDataStore("playerData")
local coolfolder = game.Workspace:WaitForChild("CoolFolder")
local saveTab = {}
local function makeTab(folder)
for i,v in pairs(folder:GetChildren()) do
local intValue = Instance.new("IntValue")
intValue.Name = v.Name..i
table.insert(saveTab, intValue)
end
end
makeTab(coolfolder)
print(saveTab[1].Name)
local function playerAdded(player)
local userId = player.UserId
local success, response = pcall(function()
return playerData:GetAsync(userId)
end)
if success then
print("ya")
end
if not response then
print("new player")
else
print(response[1].Name)
end
end
local function playerRemoved(player)
local userId = player.UserId
local success, response = pcall(function()
playerData:SetAsync(userId, saveTab)
end)
if success then
print("Data saved successfully")
else
warn("Data didn't save")
end
end
--Events
Players.PlayerAdded:Connect(playerAdded)
Players.PlayerRemoving:Connect(playerRemoved)

