Why does welding a group of blocks in place fail when the parts are not anchored?
Asked by
6 years ago Edited 6 years ago
I have a script that welds a group of blocks in a model to its primary part in place.
When they are not anchored, all the parts are not welded in their place, instead, they all teleport to the position of the primary part and is welded at that position.
What I mean:
Unwelded Island and Welding when not anchored: https://imgur.com/a/s2xqiE3
Code snippet:
Gui has a button that once clicked will get the model from the textbox, then finds the primary part, then uses the applyOnChildren method to call the weldToPrimaryPart function between each part and the primary part.
01 | function applyOnChildren(p, f, args) |
03 | local children = p:getChildren() |
04 | for index = 1 , #children do |
05 | f(children [ index ] ,args) |
09 | function weldToPrimaryPart(part,primary) |
11 | local w = Instance.new( "ManualWeld" ) |
15 | w.C 0 = primary.CFrame:inverse() * part.CFrame |
21 | applyOnChildren(model,weldToPrimaryPart,model.PrimaryPart) |
26 | local modelName = gui.WeldFrame.ModelName.Text |
28 | if not (isempty(modelName)) then |
30 | local model = workspace:FindFirstChild(modelName) |