Is there a way to delete a named/specific attachment?

When running this code, it doesn’t delete the specific part in a model. Is there a way I could do it?

for a=1,1 do
	local RS = game.ReplicatedStorage.folder
	local attach1 = Instance.new("Attachment")
	local pe1 = RS.Star:Clone()
	attach1.Name = "Attach1"
	attach1.CFrame = CFrame.new(0, 0, 0)
	pe1.Parent = attach1
	attach1.Parent = pl
end

for i,v in pairs(pl:GetChildren()) do
	if v:IsA("Attach1") then -- Here is where I want to change, instead of using "Attachment"
	v:Remove()
	end
end

You need to check the name using .Name, not IsA(). The IsA function checks for the Type of the object, which in this case is simply “Attachment”.
if v.Name == "Attach1" then

1 Like

Ah thank you. I realized my mistake there.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.