It returns no errors in the log
--Macros
local det = script.Parent
local welds
local touching
function reinit()
welds = det.Welds:GetChildren()
touching = det:GetTouchingParts()
end
--Main
function CorD()
print(#welds)
if #welds == 0 then
for i = 1,#touching do
local weld = Instance.new("Weld")
weld.Part0 = det
weld.Part1 = welds[i]
weld.C0 = det.CFrame:inverse()
weld.C1 = touching[i].CFrame:inverse()
weld.Parent = det.Welds
end
else
end
reinit()
end
reinit()
det.ClickDetector.MouseClick:connect(CorD)

1 comment
print(#welds) is for debug