Save Script:
local PetsTable = {}
for i, pet in pairs(player.Pets:GetChildren()) do
table.insert(PetsTable, pet.Name)
end
local Psuccess, Perr = pcall(function()
PetDataStore:SetAsync(player.UserId, PetsTable)
end)
Load Script:
local Pdata
local Psuccess, Perr = pcall(function()
Pdata = DataStore:GetAsync(player.UserId)
end)
if Psuccess and Pdata then
for i, pet in pairs(Pdata) do
local PetValue = Instance.new("NumberValue")
PetValue.Name = pet
PetValue.Value = Pets:FindFirstChild(pet, true):GetAttribute("Multiplier")
PetValue.Parent = player.Pets
end
end
When I print ‘pet.Name’ in the Save Script after the ‘table.insert’ line, it prints the pet’s name. Though, when I print ‘pet’ in the Load Script after the ‘for i, pet in pairs(Pdata) do’ line, it prints ‘0’. I’m not sure why.
Any help is appreciated!