Uh hello, Also I tried to do a Value saving script also it saves multiple and I became this error: Cannot store Array in data store. Data stores can only accept valid UTF-8 characters. How could I fix this?
Script: l
ocal DS = game:GetService("DataStoreService")
local PetDS = DS:GetDataStore("PetDataStore")
local PetsTable = {}
local AUTOSAVE_INTERVAL = 60
game.Players.PlayerAdded:Connect(function(Player)
local PetsFolder = Instance.new("Folder")
PetsFolder.Name = "Pets"
PetsFolder.Parent = Player
local key = Player.UserId
PetsTable = PetDS:GetAsync()
if PetsTable then
for _,p in pairs (PetsTable) do
local In = Instance.new("IntValue")
In.Name = p["Name"]
In.Parent = PetsFolder
In.Value = p["Value"]
end
end
end)
game.Players.PlayerRemoving:Connect(function(Player)
for _,p in pairs (PetsTable) do
table.remove(PetsTable,p)
end
for _,i in pairs (Player.Pets:GetChildren()) do
if i then
table.insert(PetsTable,i)
PetsTable[i] = {}
table.insert(PetsTable[i],"Name")
table.insert(PetsTable[i], "Value")
PetsTable[i]["Name"] = i.Name
PetsTable[i]["Value"] = i.Value
print(PetsTable[i]["Name"])
PetDS:SetAsync(Player.UserId, PetsTable)
end
end
end)
Would be great!

1 comment
call SetAsync outside after the loop