Previized

Weld Script

Dec 26th, 2020 (edited)
2,329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.60 KB | None | 0 0
  1. --// This is better Weld code than in my video, so use this instead!
  2. function Weld()
  3.     local parts,last = {}
  4.     local function scan(parent)
  5.         for _,v in pairs(parent:GetChildren()) do
  6.             if (v:IsA('BasePart')) then
  7.                 if (last) then
  8.                     local w = Instance.new('Weld')
  9.                     w.Name = ('Weld')
  10.                     w.Part0,w.Part1 = last,v
  11.                     w.C0 = last.CFrame:inverse()
  12.                     w.C1 = v.CFrame:inverse()
  13.                     w.Parent = last
  14.                 end
  15.                 last = v
  16.                 table.insert(parts,v)
  17.             end
  18.             scan(v)
  19.         end
  20.     end
  21.     scan(script.Parent)
  22.     for _,v in pairs(parts) do
  23.         v.Anchored = false
  24.     end
  25. end
  26.  
  27. Weld()
  28. script:Remove()
Add Comment
Please, Sign In to add comment