Hello, so i’m currently trying to save children of a folder inside the player but it wont work i don’t know whats wrong with my script the output don’t say any errors here it is:
local datastoreservice = game:GetService("DataStoreService")
local mydata2 = datastoreservice:GetDataStore("cooldata")
game.Players.PlayerAdded:Connect(function(player)
local fodler = Instance.new("Folder",player)
fodler.Name = "TestFolder"
local mydata
local success, errormsg = pcall(function()
local mydata = mydata2:GetAsync(player.UserId)
end)
if mydata ~= nil then
if mydata.TestFolder then
for i, v in pairs(mydata.TestFolder) do
local val = Instance.new("StringValue")
val.Name = v
val.Parent = fodler
end
end
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local mydata = {}
mydata.TestFolder = {}
for i, v in pairs(player.TestFolder:GetChildren()) do
table.insert(mydata.TestFolder, v.Name)
print(v.Name)
end
local success, errormsg = pcall(function()
mydata2:SetAsync(player.UserId,mydata)
end)
if success then
print("your data was saved")
end
end)
Thank you!