Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. local Tool = script.Parent
  2. local Remote = Tool:WaitForChild("Remote")
  3. local mouseDown = false
  4. local tip = Tool.Tip
  5. local sound = Tool.Sound
  6.  
  7. local Weld
  8. local Motor
  9. local MotorPart0
  10. local MotorPart1
  11.  
  12. function getPlayer()
  13. return game:GetService("Players"):GetPlayerFromCharacter(Tool.Parent)
  14. end
  15.  
  16. -------------------------------------------------------
  17. local attachment
  18.  
  19. function mDown(target)
  20. mouseDown = true
  21.  
  22. local H, max
  23. if target.Parent.Name == "Doorcontrol" then
  24. attachment = Instance.new("Attachment")
  25. attachment.Parent = target
  26. tip.Beam.Attachment1 = attachment
  27. max = 800
  28. target.Parent.Dynamics.Door.Value.BillBoardGui.Main.Health = 'Health: ' .. target.Parent.Dynamics.Door.Value.Parent.Health.Value .. '/800'
  29. H = target.Parent.Dynamics.Door.Value.Parent.Health
  30. return
  31. end
  32. tip.ParticleEmitter.Enabled = true
  33. tip.PointLight.Enabled = true
  34. sound:Play()
  35.  
  36. while H and mouseDown and H.Value < max do
  37. H.Value = H.Value + 1
  38. wait()
  39. target.Parent.Dynamics.Door.Value.BillBoardGui.Main.Health = 'Health: ' .. target.Parent.Dynamics.Door.Value.Parent.Health.Value .. '/800'
  40. end
  41.  
  42. end
  43.  
  44. function mUp()
  45. mouseDown = false
  46. tip.ParticleEmitter.Enabled = false
  47. tip.PointLight.Enabled = false
  48. sound:Stop()
  49. if attachment then
  50. attachment:Destroy()
  51. end
  52. end
  53.  
  54. -------------------------------------------------------
  55. function setPointDirection(position)
  56. local char = Tool.Parent
  57. if not char then return end
  58.  
  59. if not Weld then
  60. Motor = char.Torso["Right Shoulder"]:Clone()
  61. MotorPart0 = char.Torso
  62. MotorPart1 = char["Right Arm"]
  63.  
  64. Weld = Instance.new("Weld")
  65. Weld.Part0 = char.Torso
  66. Weld.Part1 = char["Right Arm"]
  67. Weld.C0 = CFrame.new(1, 1, 0)
  68. Weld.Parent = Weld.Part0
  69. end
  70.  
  71. local jointPosition = Weld.Part0.CFrame:toWorldSpace(CFrame.new(1, 0.5, 0))
  72. local cframe = CFrame.new(jointPosition.p, position) * CFrame.Angles(math.pi/2, 0, 0) * CFrame.new(0, -1, 0)
  73. Weld.C0 = Weld.Part0.CFrame:toObjectSpace(cframe)
  74. end
  75.  
  76.  
  77. function onRemote(player, func, ...)
  78. if player ~= getPlayer() then return end
  79.  
  80. if func == "UpdateDirection" then
  81. --setPointDirection(...)
  82. elseif func == "Down" then
  83. mDown(...)
  84. elseif func == "Up" then
  85. mUp()
  86. end
  87. end
  88.  
  89. function onUnequipped()
  90. if Weld then
  91. Weld:Destroy()
  92. Weld = nil
  93. end
  94.  
  95. if Motor then
  96. Motor.Part0 = MotorPart0
  97. Motor.Part1 = MotorPart1
  98. Motor.Parent = MotorPart0
  99. Motor = nil
  100. end
  101. end
  102.  
  103. Remote.OnServerEvent:connect(onRemote)
  104. --Tool.Unequipped:connect(onUnequipped)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement