Video
local EquippedPetsDataString = EquippedPetsData:GetAsync(plr.UserId)
if EquippedPetsDataString ~= nil then
for i,v in pairs(EquippedPetsDataString) do
local NewPodEquippedData = Instance.new("StringValue", plr.EquippedPets)
NewPodEquippedData.Name = tostring(v)
local Newpet = game.ReplicatedStorage.PetIndex[tostring(v)]:Clone()
Newpet.Parent = workspace.Player_Pets:FindFirstChild(plr.Name)
plr.PetMultiplier.Value += Newpet.Multiplier.Value
plr.PetsEquippedNumber.Value += 1
end
end
the code that loads in pets back into workspace.
function UpdatePlayersPets(NewPet)
local cloendpet = NewPet:Clone()
local clonedTemplate = script.PetButtonUi:Clone()
clonedTemplate.Name = cloendpet.Name
clonedTemplate.Parent = script.Parent.PetInventoryFrame.Frame.innerFrame.PetButtonHolder
cloendpet.Parent = clonedTemplate.PetModelHolder
local NewCam = Instance.new("Camera", clonedTemplate)
clonedTemplate.PetModelHolder.CurrentCamera = NewCam
clonedTemplate.Name = cloendpet.Name
clonedTemplate.PetName.Text = cloendpet.Name
clonedTemplate.PetMulti.Text = "x"..cloendpet.Multiplier.Value
NewCam.CFrame = CFrame.new(cloendpet.PrimaryPart.Position)
the code that creates the templates when player rejoins.
task.wait(4)
for i,v in pairs(plr.Pets:GetChildren()) do
if v:IsA("StringValue") then
local Pet = game.ReplicatedStorage.PetIndex[v.Name]
UpdatePlayersPets(Pet)
end
end
the code that loops through pets and calls the function.