I have a pet system, it works as it should, but there is one problem with crafting pets, when I craft 5 pets into one, new cooler ones appear and for some reason the old ones remain in place and are not deleted
how to fix this?
local RS = game.ReplicatedStorage
local Inventory = script.Parent.Parent.Parent.Parent.MainFrame.Inventory
script.Parent.MouseButton1Click:Connect(function()
local Result, Message = RS.RemoteEvents.PetActionRequest:InvokeServer("Craft", {PetID = script.Parent.Parent.Parent.PetID.Value})
if Result ~= nil and Result ~= "Error" then
for _, sus in pairs(Inventory:GetChildren()) do
if sus.Name ~= "UIGridLayout" and sus.Background.BackgroundColor3 == Inventory.Parent.SelectButtonColor.Value then
sus:Destroy()
end
end
local Disabled = false
script.Parent.Parent.Parent.PetID.Value = 0
for i,v in pairs(Inventory:GetChildren()) do
if v:IsA("Frame") then
v.Background.BackgroundColor3 = Inventory.Parent.DefaultButtonColor.Value
end
end
elseif Result == "Error" then
print(Message)
end
end)