Advertisement
Guest User

Untitled

a guest
May 26th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.39 KB | None | 0 0
  1. --!
  2.  
  3. tool = script.Parent
  4. handle = tool.Handle
  5. keys = {}
  6.  
  7. gui = tool.MedigunGui
  8. frame = gui.Frame
  9.  
  10. function getPlayer()
  11. return tool.Parent:IsA("Backpack") and tool.Parent.Parent.Parent or game.Players:GetPlayerFromCharacter(tool.Parent)
  12. end
  13.  
  14. function onHandleTouched(other)
  15. local human = other.Parent:FindFirstChild("Humanoid")
  16. if not human then return end
  17. local player = game.Players:GetPlayerFromCharacter(other.Parent)
  18. if not player then return end
  19. end
  20.  
  21. function raycast(cf)
  22. local ray = Ray.new(cf.p, cf.lookVector * 200)
  23. return workspace:FindPartOnRay(ray, tool.Parent)
  24. end
  25.  
  26. function noTargetSound()
  27. handle.medigun_no_target:Stop()
  28. handle.medigun_no_target:Play()
  29. end
  30.  
  31. function onActivated()
  32. frame.Visible = false
  33. holding = true
  34. local p = tool.Parent.Humanoid.TargetPoint
  35. local n = raycast(CFrame.new(handle.Position,p))
  36. if n then
  37. local human = n.Parent:FindFirstChild("Humanoid")
  38. if human and human.Health > 0 then
  39. local dist = (human.Torso.Position - handle.Position).magnitude
  40. if dist > tool.Distance.Value then noTargetSound() return end
  41. gui.Lasso.Part = tool.Head
  42. gui.Lasso.Humanoid = human
  43. gui.Lasso.Color = tool.ActiveColor.Value
  44. tool.Head.BrickColor = tool.ActiveColor.Value
  45. tool.Bar.BrickColor = tool.ActiveColor.Value
  46. local sparkles = Instance.new("Sparkles")
  47. sparkles.SparkleColor = tool.ActiveColor.Value.Color
  48. sparkles.Enabled = false
  49. sparkles.Parent = human.Torso
  50. sparkles.Archivable = false
  51. local fire = Instance.new("Fire")
  52. fire.SecondaryColor = tool.ActiveColor.Value.Color
  53. fire.Parent = human.Torso
  54. fire.Archivable = false
  55. handle.medigun_heal:Stop()
  56. handle.medigun_heal:Play()
  57. local s1 = Instance.new("Sound")
  58. s1.SoundId = "http://www.roblox.com/asset/?id=10756104"
  59. s1.Volume = 1
  60. s1.Pitch = 1.25
  61. s1.Parent = human.Torso
  62. s1.Looped = true
  63. s1:Play()
  64. local s2 = Instance.new("Sound")
  65. s2.SoundId = "http://www.roblox.com/asset/?id=170791927"
  66. s2.Volume = 0.4
  67. s2.Pitch = 1
  68. s2.Looped = true
  69. s2.Parent = human.Torso
  70. Spawn(function ()
  71. wait(0)
  72. s2:Play()
  73. end)
  74. frame.Visible = true
  75. frame.TextLabelTargetName.Text = human.Parent.Name
  76. while holding and equipped do
  77. if human.Health <= 0 then break end
  78. local dist = (human.Torso.Position - handle.Position).magnitude
  79. if dist > tool.Distance.Value then noTargetSound() break end
  80. human.Health = math.min(human.MaxHealth, human.Health + tool.Rate.Value)
  81. local p = human.Health / human.MaxHealth
  82. frame.FrameHealth.Bar.Size = UDim2.new(1, 0, p * -1, 0)
  83. frame.FrameHealth.TextLabelPerc.Text = math.ceil(100 * p) .. "%"
  84. if human.Health < human.MaxHealth * .8 then
  85. sparkles.Enabled = false
  86. fire.Color = tool.Color.Value.Color
  87. else
  88. sparkles.Enabled = true
  89. fire.Color = tool.ActiveColor.Value.Color
  90. fire.Size = (math.sin(tick() * 5) + 1) / 2 * 2 + 4
  91. end
  92. wait()
  93. end
  94. Spawn(function ()
  95. for i = 1, 0, -.1 do wait() s1.Volume = i s2.Volume = i end
  96. s1:Stop()
  97. s2:Stop()
  98. s1:Destroy()
  99. s2:Destroy()
  100. end)
  101. sparkles.Enabled = false
  102. game.Debris:AddItem(sparkles, 3)
  103. fire.Enabled = false
  104. game.Debris:AddItem(fire, 3)
  105. gui.Lasso.Color = tool.Color.Value
  106. tool.Head.BrickColor = tool.Color.Value
  107. tool.Bar.BrickColor = tool.Color.Value
  108. gui.Lasso.Part = nil
  109. frame.Visible = false
  110. else
  111. noTargetSound()
  112. end
  113. end
  114. end
  115.  
  116. function onDeactivated()
  117. holding = false
  118. gui.Lasso.Part = nil
  119. end
  120.  
  121. function onKeyDown(key)
  122. end
  123.  
  124. function onKeyUp(key)
  125. end
  126.  
  127. function onEquipped()
  128. frame.Visible = false
  129. frame.BackgroundColor3 = tool.Color.Value.Color
  130. tool.Head.BrickColor = tool.Color.Value
  131. tool.Bar.BrickColor = tool.Color.Value
  132. gui.Parent = getPlayer():FindFirstChild("PlayerGui")
  133. gui.Lasso.Part = nil
  134. end
  135.  
  136. function onUnequipped()
  137. gui.Parent = tool
  138. end
  139.  
  140. tool.Equipped:connect(function (m)
  141. m.KeyDown:connect(function (k) keys[k] = true onKeyDown(k) end)
  142. m.KeyUp:connect(function (k) keys[k] = nil onKeyUp(k) end)
  143. equipped = true onEquipped(m)
  144. end)
  145. tool.Unequipped:connect(function () holding = false equipped = false onUnequipped() end)
  146. tool.Activated:connect(function () holding = true onActivated() end)
  147. tool.Deactivated:connect(function () holding = false onDeactivated() end)
  148. handle.Touched:connect(function (...) onHandleTouched(...) end)
  149.  
  150. --10/14/12 1:51 PM
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement