Edit: so, i’ve tried the solutions so far and it worked but the problem now is that its cloning the pets with the PetsEquiped empty.
Code:
game.Players.PlayerAdded:connect(function(p)
local statss = Instance.new("Folder")
statss.Name = "PetsEquiped"
statss.Parent = p
for i,v in pairs(game.ReplicatedStorage:WaitForChild("Pets"):GetChildren()) do
local PE = Instance.new("IntValue")
PE.Name = tostring(v)
PE.Parent = statss
end
local data = dataStore:GetAsync(p.UserId)
if data then
print(data[1])
for _,stat in pairs(statss:GetChildren()) do
stat.Value = data[1]
end
local equiped = p.PetsEquiped:GetChildren()
if equiped ~= nil then
p.CharacterAdded:Connect(function(char)
for i,v in pairs(equiped) do
local a = game.ReplicatedStorage.Pets[v.Name]:Clone()
a.Name = v.Value
a.Parent = char.HumanoidRootPart
end
end)
else
print("Nope")
end
else
print(p.Name .. " has no pets equiped when left")
end
end)
Example of Issue(You can’t see the actual issue clearly but you can see the particle emitter overlapping behind the pet, which isn’t originally suppose to do):