WeldConstraints weird bug

Hey!

I’ve recently been working on a door framework for my game.

It all seemed to work fine, and still does. Except for the fact that as of recently, any new doors don’t work.

I use WeldConstraints to move the objects, and that’s been working fine for me.
But now, whenever I copy any of the doors (even if duplicating, or using ctrl+c; they’re the exact same), the welds fail to work on them.
The welds go inactive without any apparent reason. However, all old doors work just fine. This only happens with new doors.

I’m not sure what’s wrong.

function WeldModel(Main, Weld)
	if not Main then return end
	if not Weld then return end
	
	for _, v in ipairs(Weld:GetDescendants()) do
		if v ~= Main and v:IsA('BasePart') then
        	local weld = Instance.new('WeldConstraint')
		
         	weld.Part0 = v
         	weld.Part1 = Main
         	
         	weld.Parent = v
			
         	v.Anchored = false
    	end
	end
end

Keep in mind this code has worked since I first wrote it, and still does. The issue is that welds are going inactive for some reason.

Any clues? Anyone else facing the same problem?

3 Likes

When you copy the door, make sure to create NEW weld constraints for them too!
The old weld constraints work just fine, but you need to make new ones for the duplicated doors.

1 Like

The welds are done automatically as seen in my original post. I have a script that creates the welds during the first door interaction.

Unable to reproduce this problem at all. Here’s what I tried:

  1. Created a brick.
  2. Duplicated that brick and moved it slightly up.
  3. Connected both bricks with a WeldConstraint.
  4. Used the duplicate context option, moved it over.
  5. Ctrl + C and Ctrl + V on both bricks, moved them over.

WeldConstraints never deactivated. The only circumstance that a WeldConstraint went inactive on me was when I toggled the anchored property on both connected parts.

Are you able to provide a repro file in which you encounter this issue or is the issue only observable to a specific assembly that you’ve created? If it’s specific to your assembly, it’s almost definitely a problem with your implementation. If you’re able to repro it on other assemblies, then the possibility of a bug is also thrown into the equation, though I doubt the latter is the case.

As stated in my original post, the welds are created through a script, and not manually.

I have created a repro place for this issue.

When you run or play solo, you’ll notice the gate on the left and the middle bug out, but the gate on the right works perfectly fine.

However, they’re all the exact same gates.

You can test this out yourself here:
weird weld bug.rbxl (22.7 KB)

2 Likes

Problem is that the baseplate has a bunch of rigid welds in it which are holding the doors down and overriding the WeldConstraints. Delete all the welds in the baseplate and try again. Doors work fine, you just had some oversights you didn’t account for.

1 Like

That’s odd. I don’t recall placing any welds at all in the baseplate. Might have to do with some recent roblox update. Will check if this fixes the issue when I can. Thanks for the discovery.

If it helps: check out BasePart.GetConnectedParts.

You can pass the descendants of each door through this function, which will return a list of connected parts via any kind of rigid joint. You can then iterate through the returned list of parts. For those that aren’t a descendant of the door model, break the joint between them.

I ran this function on a part of one of the “faulty” doors and the Baseplate was in the returned array.

1 Like

The issue is that it was a brand new place. The baseplate shouldn’t have any welds at all.

I’m not sure I understand your response clearly. As far as baseplate welds go though, this most likely has to do with the new part surface behaviour that creates welds when you drag bricks around. T
I noticed it happens for me too. Turn off “Join Surfaces”.

3 Likes