i saved the valu of the name and the value to datastore, and when the player leaves it does save ichecked all the values in the table but when i join back i cant set it to those values, it takes the defult name and value from replicatedstorage
-- players.PlayerAdded:Connect(function(plr)
local charms = Instance.new("Folder",plr)
charms.Name = "Charms"
local owendC = plr:WaitForChild("Charms")
local charmsowned = {}
pcall(function()
charmsowned = data:GetAsync(plr.UserId) or {}
end)
for i,own in pairs(charmsowned) do
if CHarms:FindFirstChild(i) then
local clone = CHarms[i]:Clone()
pcall(function()
for val,v in pairs(own) do
if clone:FindFirstChild(val) then
print(v[("name")])
print(v[("value")])
clone[val].Value = v[("value")]
clone[val].Name = v[("name")]
end
end
end)
clone.Parent = owendC
else
owendC = charmsowned
end
end
end)
function plrLeaving(plr)
local ownedcharms = {}
for i , charm in pairs(plr.Charms:GetChildren()) do
local tbl = {}
for _ , child in pairs(charm:GetChildren()) do
tbl[child.Name] = {["value"] = child.Value; ["name"] =child.Name}
end
ownedcharms[charm.Name] = tbl
print(ownedcharms)
end
local s,e = pcall(function()
data:SetAsync(plr.UserId,ownedcharms)
end)
if s then
print(s)
else
print(e)
end
end
players.PlayerRemoving:Connect(plrLeaving)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.