Advertisement
clutchHorizon

ROBLOX

Oct 28th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. --MADE BY NWSPACEK
  2.  
  3. --[[ This weld script is cool!
  4. It will use the structure of models to weld. It treats each model as a separate moving body
  5. except if name a part "AHandle" and insert a BoolValue named "WeldToRoot" into it.
  6. --]]
  7.  
  8. wait(1) --thanks PSG
  9.  
  10. local AvoidWelding = {--add models you want this script to not weld in here
  11. ["Coupler"]=true
  12. }
  13.  
  14. function weld(i,b)
  15. local weld1 = Instance.new("Weld")
  16. weld1.Name = b.Name
  17. weld1.Part0 = i
  18. weld1.Part1 = b
  19. weld1.C1 = b.CFrame:inverse()*i.CFrame
  20. weld1.Parent = i
  21. end
  22.  
  23. function welding(p,ph)
  24. p:MakeJoints()
  25. local handle = p:FindFirstChild("AHandle")
  26. if handle and ph and handle:FindFirstChild("WeldToRoot") then
  27. weld(handle,ph)
  28. end
  29. if not handle then
  30. for _,j in pairs (p:GetChildren()) do
  31. if j:IsA("BasePart") then
  32. handle = j
  33. break
  34. end
  35. end
  36. end
  37. if not handle then
  38. handle = ph
  39. end
  40. for _,j in pairs (p:GetChildren()) do
  41. if j:IsA("BasePart") then
  42. weld(handle,j)
  43. elseif j:IsA("Model") and not AvoidWelding[j.Name] then
  44. welding(j,handle)
  45. end
  46. end
  47. end
  48.  
  49. function unanchoring(p)
  50. for _,j in pairs (p:GetChildren()) do
  51. if j:IsA("BasePart") then
  52. j.Anchored = false
  53. elseif j:IsA("Model") then
  54. unanchoring(j)
  55. end
  56. end
  57. end
  58.  
  59. wait(1)
  60. welding(script.Parent)
  61. wait(0.5)
  62. unanchoring(script.Parent)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement