Making a new instance and deleting the old one inside a for loop

i made a script for this door to automatically change the weld types (as shown below)

for i, v in pairs(game.Workspace.DoorThatNeverGoesWell) do
	if v.ClassName == "Weld" then
		local newWeld = Instance.new("WeldConstraint")
		newWeld.Part0 = v.Part0
		newWeld.Part1 = v.Part1
		newWeld.Parent = v.Parent

		v:Destroy()
	end
end

edit: before you start replying, please note that i used :IsA() before

i don’t know what you want with this? maybe you forgot the GetChildren() ?

wait a minute
i forgor that :skull:

but i’ve actually put getchildren before

nope, doesn’t work. Thank you though!

i still don’t get what your issue is though…

my bad everyone who viewed this. I apologize for my inconvenience. I actually need to put GetDescendants() and not GetChildren()

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