Advertisement
mathmasterphil

Ditto

Mar 1st, 2015
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.74 KB | None | 0 0
  1. me = game.Players.mathmasterphil
  2. hold = true
  3. grab = nil
  4. pos = nil
  5. dis = 0
  6. head = me.Character.Head
  7.  
  8. function prop(part, parent, collide, tran, ref, x, y, z, color, anchor, form)
  9. part.Parent = parent
  10. part.formFactor = form
  11. part.CanCollide = collide
  12. part.Transparency = tran
  13. part.Reflectance = ref
  14. part.Size = Vector3.new(x,y,z)
  15. part.BrickColor = BrickColor.new(color)
  16. part.TopSurface = 0
  17. part.BottomSurface = 0
  18. part.Anchored = anchor
  19. part.Locked = true
  20. part:BreakJoints()
  21. end
  22.  
  23. function getparts(path)
  24. local objs = {}
  25. for _,v in pairs(path:children()) do
  26. if v:IsA("BasePart") then
  27. if v:GetMass() < 100 then
  28. table.insert(objs,v)
  29. end
  30. end
  31. for _,k in pairs(v:children()) do
  32. if k:IsA("BasePart") then
  33. if k:GetMass() < 100 then
  34. table.insert(objs,k)
  35. end
  36. end
  37. for _,j in pairs(k:children()) do
  38. if j:IsA("BasePart") then
  39. if j:GetMass() < 100 then
  40. table.insert(objs,j)
  41. end
  42. end
  43. end
  44. end
  45. end
  46. return objs
  47. end
  48.  
  49. trail = Instance.new("Part")
  50. prop(trail,nil,false,0.2,0,0.6,0.6,1,"Bright red",true,"Custom")
  51. tm = Instance.new("SpecialMesh",trail)
  52. tm.MeshType = "Brick"
  53. tm.Scale = Vector3.new(1,1,1)
  54.  
  55. trail2 = Instance.new("Part")
  56. prop(trail2,nil,false,0.2,0,0.6,0.6,1,"Bright red",true,"Custom")
  57. tm2 = Instance.new("SpecialMesh",trail2)
  58. tm2.MeshType = "Brick"
  59. tm2.Scale = Vector3.new(1,1,1)
  60.  
  61. if script.Parent.className ~= "HopperBin" then
  62. h = Instance.new("HopperBin",me.Backpack)
  63. h.Name = "Lazor"
  64. script.Parent = h
  65. end
  66. bin = script.Parent
  67.  
  68. bin.Selected:connect(function(mouse)
  69. mouse.Button1Down:connect(function()
  70. hold = true
  71. trail.Parent = me.Character
  72. while hold do
  73. if pos == nil then
  74. dis = (head.Position - mouse.Hit.p).magnitude
  75. end
  76. tm.Scale = Vector3.new(1,1,dis)
  77. trail.CFrame = CFrame.new(head.Position, mouse.Hit.p) * CFrame.new(0,0,-dis/2)
  78. if pos ~= nil then
  79. pos.position = trail.CFrame * CFrame.new(0,0,-dis/2).p
  80. if grab ~= nil then
  81. if trail2.Parent == nil then
  82. trail2.Parent = me.Character
  83. trail.Transparency = 1
  84. end
  85. trail2.CFrame = CFrame.new(head.Position, grab.Position) * CFrame.new(0,0,-(head.Position - grab.Position).magnitude/2)
  86. tm2.Scale = Vector3.new(1,1,(head.Position - grab.Position).magnitude)
  87. end
  88. end
  89. local parts = getparts(workspace)
  90. for _,v in pairs(parts) do
  91. if grab == nil and bp == nil then
  92. if (v.Position - trail.CFrame * CFrame.new(0,0,-dis/2).p).magnitude < 3 then
  93. grab = v
  94. local bp = Instance.new("BodyPosition",v)
  95. bp.maxForce = Vector3.new(math.huge,math.huge,math.huge)
  96. bp.P = 25000
  97. bp.position = trail.CFrame * CFrame.new(0,0,-dis/2).p
  98. pos = bp
  99. end
  100. end
  101. end
  102. wait()
  103. end
  104. end)
  105. mouse.Button1Up:connect(function()
  106. hold = false
  107. trail.Parent = nil
  108. if pos ~= nil then
  109. pos:remove()
  110. pos = nil
  111. end
  112. if grab ~= nil then
  113. grab = nil
  114. end
  115. trail.Parent = nil
  116. trail.Transparency = 0.2
  117. trail2.Parent = nil
  118. end)
  119. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement