DANIOS

bridge tool

Apr 1st, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1.  
  2. me = game.Players.LocalPlayer
  3. h = Instance.new("HopperBin")
  4. h.Parent = me.Backpack
  5. h.Name = "Bridge Tool"
  6. bridges = {}
  7. hold = false
  8. using = false
  9. holdkey = false
  10. polesize = 5
  11. function selected(mouse, key)
  12. mouse.Button1Down:connect(function()
  13. if mouse.Target == nil then return end
  14. if using == true then return end
  15. using = true
  16. hold = true
  17. pos = mouse.Hit.p
  18. p = Instance.new("Part")
  19. p.Parent = workspace
  20. p.formFactor = 0
  21. p.Size = Vector3.new(5,1,1)
  22. p.Anchored = true
  23. p.Transparency = 0.6
  24. p.TopSurface = 0
  25. p.BrickColor = BrickColor.new("Brown")
  26. p.BottomSurface = 0
  27. p.CFrame = CFrame.new(pos)
  28. mes = Instance.new("SpecialMesh")
  29. mes.Parent = p
  30. mes.MeshType = "Brick"
  31. mes.Scale = Vector3.new(1,1,1)
  32. table.insert(bridges, p)
  33. mouse.Move:connect(function()
  34. if mouse.Target == nil then return end
  35. if hold == true then
  36. local dist = (p.Position - mouse.Hit.p).magnitude
  37. p.CFrame = CFrame.new((mouse.Hit.p + pos)/2, pos)
  38. mes.Scale = Vector3.new(1,1,dist*2)
  39. end
  40. end)
  41. end)
  42. mouse.Button1Up:connect(function()
  43. hold = false
  44. local duh = p.CFrame
  45. p.Size = Vector3.new(5,1,mes.Scale.Z)
  46. p.CFrame = duh
  47. mes:remove()
  48. for i=1, 5 do
  49. wait()
  50. p.Transparency = p.Transparency - 0.12
  51. end
  52. p.Material = "Wood"
  53. using = false
  54. end)
  55. mouse.KeyDown:connect(function(key)
  56. key = key:lower()
  57. if (key == "r") then
  58. for i=1, #bridges do
  59. bridges[i]:remove()
  60. end
  61. elseif (key == "q") then
  62. polesize = polesize - 1
  63. local ms = Instance.new("Message")
  64. ms.Parent = me
  65. ms.Text = "Pole size decreased to "..polesize
  66. wait(0.4)
  67. ms:remove()
  68. elseif (key == "e") then
  69. polesize = polesize + 1
  70. local ms = Instance.new("Message")
  71. ms.Parent = me
  72. ms.Text = "Pole size increased to "..polesize
  73. wait(0.4)
  74. ms:remove()
  75. elseif (key == "f") then
  76. if mouse.Target == nil then return end
  77. if using == true then return end
  78. using = true
  79. holdkey = true
  80. po = Instance.new("Part")
  81. po.Parent = workspace
  82. po.formFactor = 0
  83. po.Size = Vector3.new(1,1,1)
  84. po.Anchored = true
  85. po.Transparency = 0.5
  86. po.TopSurface = 0
  87. po.BrickColor = BrickColor.new("Brown")
  88. po.BottomSurface = 0
  89. mesh = Instance.new("SpecialMesh")
  90. mesh.Parent = po
  91. mesh.Scale = Vector3.new(1,polesize,1)
  92. po.CFrame = CFrame.new(mouse.Hit.p.X, mouse.Hit.p.Y + mesh.Scale.Y/2, mouse.Hit.p.Z)
  93. table.insert(bridges,po)
  94. end
  95. end)
  96. mouse.KeyUp:connect(function(key)
  97. key = key:lower()
  98. if (key == "f") then
  99. holdkey = false
  100. for i=1, 5 do
  101. wait()
  102. po.Transparency = po.Transparency - 0.1
  103. end
  104. local posi = po.CFrame
  105. po.Material = "Wood"
  106. po.Size = mesh.Scale
  107. mesh:remove()
  108. po.CFrame = posi
  109. using = false
  110. end
  111. end)
  112. end
  113. function deselected()
  114. end
  115. h.Selected:connect(selected)
  116. h.Deselected:connect(deselected)
Add Comment
Please, Sign In to add comment