On the 3rd of November, my game which involves a lot of WeldConstraints on moving parts suddenly broke without any update from me. Upon further investigation, I have narrowed down the cause of the issue to be with the way WeldConstraints behave. The documentation states that changing the position of a part that is welded will simply recalculate its offset from the part it is welded to. However, this behaviour is now broken.
REPRO:
This can be reproduced simply by using this code listed on the documentation:
local partA = Instance.new("Part")
local partB = Instance.new("Part")
partA.Position = Vector3.new(0, 10, 0)
partB.Position = Vector3.new(0, 10, 10)
partA.Parent = workspace
partB.Parent = workspace
-- Weld the two parts together
local weld = Instance.new("WeldConstraint")
weld.Parent = workspace
weld.Part0 = partA
weld.Part1 = partB
-- Update the position of the first part; the first part will move but the second will stay where it started
partA.Position = Vector3.new(0, 20, 0)
.rbxl place file: WeldBugReport.rbxl (20.5 KB)
Here is a video of what happens when this code is run. Notice that the parts appear in different positions on the client and the server:
Here is a further video where I used the following code. Notice how the part that is being repositioned is snapped to the center point of the part it is welded to:
local wall = workspace.BackWall
local root = workspace.ROOT
local rootC = root.CFrame
wait(10)
wall.Position = rootC * Vector3.new(0,10,0)
.rbxl place file 2: weldWeirdTest.rbxl (21.9 KB)
One more thing I have noticed is that the order of Part0
and Part1
seems to matter now. Depending on which way round they are the behaviour is different. The bug seems to happen 100% of the time when Part0
is set to the parent of the weldconstraint.
Conclusion
Thank you for taking your time to read this bug report. This issue has caused my game to become unplayable, and I am keen to understand why this might be happening and if it is possible to be fixed.