Pets disappear from players inventory when player dies?
Asked by
4 years ago Edited 4 years ago
Hello. Ive made a pet system, everything works well until the player dies. All of the pets the player had in their inventory disappear from their inventory with no errors. Does anybody know how I can fix this?
01 | local function addToFrame(pet) |
04 | local newTemplate = Template:Clone() |
05 | newTemplate.Name = pet.Name |
06 | newTemplate.PetName.Text = pet.Name |
07 | newTemplate.Parent = scrollframe |
09 | local NewPet = pet:Clone() |
10 | NewPet.Parent = newTemplate.PetImage |
12 | local camera = Instance.new( "Camera" ) |
13 | camera.CFrame = CFrame.new(NewPet.PrimaryPart.Position + (NewPet.PrimaryPart.CFrame.LookVector * 3 ),NewPet.PrimaryPart.Position) |
14 | camera.Parent = newTemplate.PetImage |
16 | newTemplate.PetImage.CurrentCamera = camera |
18 | buttonconnections [ #buttonconnections + 1 ] = newTemplate.MouseButton 1 Click:Connect( function () |
19 | if newTemplate.Equipped.Text = = "EQUIPPED" then |
21 | game.ReplicatedStorage.UnEquipPet:FireServer() |
22 | newTemplate.Equipped.Text = "UNEQUIPPED" |
23 | newTemplate.Equipped.TextColor 3 = Color 3. fromRGB( 255 , 0 , 0 ) |
25 | game.ReplicatedStorage.EquipPet:FireServer(pet.Name) |
26 | SetTemplateEquipped(newTemplate) |
32 | game.ReplicatedStorage.SendData.OnClientEvent:Connect( function (PetNames) |
34 | for i,petName in pairs (PetNames) do |
35 | if game.ReplicatedStorage.Egg 1 :FindFirstChild(petName) then |
36 | addToFrame(game.ReplicatedStorage.Egg 1 :FindFirstChild(petName)) |
42 | game.ReplicatedStorage.SetEquippedPet.OnClientEvent:Connect( function (PetName) |
43 | if scrollframe:FindFirstChild(PetName) then |
44 | SetTemplateEquipped(scrollframe [ PetName ] ) |