I made this script to save peoples owned characters using a table, but it dosent work.
There is no error.
Code :
game.Players.PlayerAdded:Connect(function(plr)
local Characters = {}
local datastore = game:GetService("DataStoreService")
local charactersavingthing = datastore:GetDataStore('DataStore'..plr.UserId)
local poop = charactersavingthing:GetAsync("CharacterData")
local chars = Instance.new('Folder',plr)
charactersavingthing:SetAsync("CharacterData",Characters)
chars.Name = "Characters"
for i,v in pairs(game.Lighting.Characters:GetChildren()) do
local charfig = Instance.new("BoolValue", chars)
charfig.Name = v.Name
charfig.Changed:Connect(function()
local c = plr.Characters:GetChildren()
for i=1,#c do
table.insert(Characters,c[i].Name.."_"..tostring(c[i].Value))
print(Characters)
end
charactersavingthing:SetAsync("CharacterData",Characters)
print(charactersavingthing)
end)
end
print(Characters)
local c = plr.Characters:GetChildren()
for i=1,#c do
table.insert(Characters,c[i].Name.."_"..tostring(c[i].Value))
print(Characters)
end
game.Players.PlayerRemoving:Connect(function(plr)
local c = plr.Characters:GetChildren()
for i=1,#c do
table.insert(Characters,c[i].Name.."_"..tostring(c[i].Value))
print(Characters)
end
print(Characters)
charactersavingthing:SetAsync("CharacterData",Characters)
end)
end)