Hello, I’m using a script to weld 2 parts together. I have made my own part movement system. I want to basically glue to parts together. My script is able to create the weld, but the problem is that when I move one of the parts, the other just stays still. Please could you help? (I’ve looked all around the dev forum, but found no solutions that work for me)
My code: (my function to create the welds/delete the welds)
local function userInput(input, gameProcessedEvent)
if not gameProcessedEvent then
if input.KeyCode == Enum.KeyCode.E then
local obj = holdingPart;
if not obj then return; end;
local touchingParts = getTouchingParts(obj);
if touchingParts[1] then
local selected:BasePart;
local _continue = true;
for _,part in ipairs(touchingParts) do
if not _continue then return; end;
if part:IsA('BasePart') and part:HasTag('pickupable') then
selected = part;
_continue = false;
end;
end;
if not selected then return; end;
local weld = Instance.new('Weld', obj);
weld.Part0 = obj;
weld.Part1 = selected;
weld.C0 = obj.CFrame:inverse() * selected.CFrame;
end;
elseif input.KeyCode == Enum.KeyCode.R then
local obj = holdingPart;
if not obj then return; end;
if obj:GetChildren() and obj:GetChildren()[1] then
for _,c in ipairs(obj:GetChildren()) do
if c:IsA('Weld') then
c:Destroy();
end;
end;
end;
end;
end;
end;
Don’t worry, there is no syntax errors, and I can assure you that the welds are actually being created.