Hello developers!
I am creating pet mass delete but when player selects one pet and another one then the first pet he selected is being duplicated.
This is how it looks (look at the Output):
script:
local petsToDelete = {}
local function onTemplatePress(temp)
selectedTemplate = temp
if isPlayerMassDeleting == true then
if selectedTemplate:FindFirstChild("UIStroke") then
selectedTemplate.UIStroke:Destroy()
selectedTemplate.Mark:Destroy()
local toRemove = table.find(petsToDelete, selectedTemplate)
table.remove(petsToDelete, toRemove)
NotificationText.Text = #petsToDelete .. " pets selected"
else
local stroke = Instance.new("UIStroke")
stroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
stroke.Color = Color3.fromRGB(255, 57, 57)
stroke.Thickness = 3
stroke.Parent = selectedTemplate
local mark = Instance.new("TextLabel")
mark.Size = UDim2.new(1,0,1,0)
mark.BackgroundTransparency = 1
mark.TextColor3 = Color3.fromRGB(255, 57, 57)
mark.Text = "X"
mark.Font = Enum.Font.FredokaOne
mark.TextScaled = true
mark.Parent = selectedTemplate
mark.Name = "Mark"
for i, v in pairs(scroller:GetChildren()) do
if v:FindFirstChild("Mark") and v:FindFirstChild("UIStroke") then
table.insert(petsToDelete, v.Name)
end
end
print(petsToDelete)
NotificationText.Text = #petsToDelete .. " pets selected"
end
else
PetInfo.Parent = temp
end
if selectedTemplate:FindFirstChild("Equipped").Value == true then
Equip.Text = "Unequip"
else
Equip.Text = "Equip"
end
PetName.Text = temp.Name
EnergyMulti.Text = "⚡x"..RepStor.Pets:FindFirstChild(temp.Name, true).Multiplier1.Value
end