so i have a script that when you unequip an item it unequips that item once even tho there are more values with the same name (It supposed to be) and it only deletes one. How do i make it delete more then one
heres the script
player.Character:FindFirstChild(v.Parent.Name):Destroy()
This is the whole unequip script
‘’'lua
elseif v.Text == “Unequip” then
v.Text = “Equip”
v.BackgroundColor3 = Color3.fromRGB(132, 255, 130)
–if player.Character:FindFirstChild(v.Parent.Name) then
player.Character:FindFirstChild(v.Parent.Name):Destroy()
player.wearTools:FindFirstChild(v.Parent.Name):Destroy()
‘’’
1 Like
You can use an ipairs loop for this.
for i, v in ipairs(Player.Character:GetChildren()) do
if v.Name == -- name
v:Destroy()
end
end
Ipairs loops basically go through the table provided (get children returns a table)
V is the instance, I is the number of the instance in the table.
1 Like