How do I destroy welds without crashing my game or them not destroying

Before anyone says it NO I am not giving you any code to delete the welds as I don’t have any.
Simple question but after 2 hours of trying the best I can do is crash my game.
I am making a roblox game but I need welds to teleport parts along with the base part but I can’t delete the welds when it is in place.

There is a welds folder in each plot and here is the generation system:

for x = 36,4000,36 do
	for z = 36,4000,36 do
		local gridpart = game.ReplicatedStorage:FindFirstChild("Grid"):WaitForChild(math.random(1,7))
		local gridclone = gridpart:Clone() -- clones and keeps in workspace
		gridclone.Parent = workspace
		gridpart.Position =,0.5,z)
		gridpart.Anchored = true
		gridpart.CanCollide = true

PS I am in a bad mood as I just wasted most of my day on this but I beg you not to ask any stupid questions/don’t be lazy and read my post and code.

1 Like

Hey! Sorry you are in a bad mood but please be patient with us if we have some honest questions. What you may want to do is put a for loop and check for all welds in the folder, once they are in there proper places, just say v:Destroy() or whatever you put for the loop parameters

1 Like

Tried that did not work (fdbshfbdshj)

Could you please show me the script you used for that?

So this is the solution based on what your title is asking, by using :GetDescendants()

local function ClearWelds(Model: Model)
	for _, v in Model:GetDescendants() do
		if v:IsA("Weld") or v:IsA("WeldConstraint") then

And if by moving welds you mean moving parts that are welded to another part, then that depends on what type of weld you are using. If you are using “Weld” then just changing its Position or CFrame should do the trick. If you’re using a “WeldConstraint” then you need to use CFrame to have a similar effect.

I also noticed that you anchor all your generated parts so I’m a bit confused as to why you require welds here? It seems a bit arbitrary since they aren’t going to be physically moving anyway.

Instead of destroying the weld can’t you just disable it?

Weld.Enabled = false

A task.wait() in your inside loop would keep the generation script from freezing up and crashing.

Tried this but all of the models get destroyed for some reason

1 Like

Models should not get destroyed using that method unless you are specifically checking to see if the object is a model. In this case we are checking to see if the objects we are iterating through are either “Welds” or “WeldConstraints”, and if they are, we destroy them.

You need to be a bit more vocal on your issue, what exactly are you trying to achieve? Your initial question makes little sense and I don’t exactly understand what the issue is, can you perhaps elaborate on your issue a bit more?

1 Like

I am making a grab system for my game witch I’m working on:

But if the parts are welded then it will crash your game because you cannot set the CFrame of a part welded to another part that is anchored (I believe)


Game is extremely unstable I will have to fix the crash but immediately

Is there a particular reason why you need to weld parts to an anchored part? Couldn’t you have the Un-Anchored part Anchored instead, and Un-Anchor it once your grab system is active?

I don’t exactly know the context of your game so I’m saying this based on assumptions. But the only reason someone would need to weld parts to anchored parts is so you have easier control over the positioning over those welded parts (by moving the anchored part), otherwise its to have complex models be physically rendered and not fall apart. If the Welded parts are not going to be moving unless you grab it, then having you toggle their Anchored state might be more beneficial

No, the game needs to teleport the parts in models to different locations so they have to be welded

Interesting concept haha.

If its just teleporting models, perhaps you could just use the :PivotTo() method? This would handle moving entire models for you regardless of whether or not the parts are welded. If your models are animated (tweening for example) then you can disregard that. But to use it you would do something like this:

Model:PivotTo(, number, number))
1 Like

got an error from this

		local vectorPos =,0.5,z)
		gridpart.Position =

Not sure what you mean, maybe I’m missing something but you haven’t applied the :PivotTo() method in your example code

1 Like

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