Advertisement
Toxicator1

weldModel

Jan 24th, 2018
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1.  
  2.  
  3. local function weldModel(model, basePart)
  4. local function weldBetween(a, b)
  5. --Make a new Weld and Parent it to a.
  6. local weld = Instance.new("ManualWeld", a)
  7. --Get the CFrame of b relative to a.
  8. weld.C0 = a.CFrame:inverse() * b.CFrame
  9. --Set the Part0 and Part1 properties respectively
  10. weld.Part0 = a
  11. weld.Part1 = b
  12. --Return the reference to the weld so that you can change it later.
  13. return weld
  14. end
  15.  
  16. for _,v in pairs(model:GetChildren()) do
  17. if v:IsA("BasePart") and v ~= basePart then
  18. weldBetween(basePart, v)
  19. elseif v:IsA("Model") then
  20. weldModel(v, basePart)
  21. end
  22. end
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement