Advertisement
Sungmingamerpro13

MedkitTool with Stacks (LocalScript)

May 16th, 2024
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.77 KB | None | 0 0
  1. local Tool = script.Parent
  2. local number = 0
  3.  
  4. local player = game.Players.LocalPlayer
  5.  
  6. -- Create the Heal function
  7. local function Heal(player)
  8.     -- Check if the player is alive
  9.     if player.Character and player.Character:FindFirstChild("Humanoid") and player.Character.Humanoid.Health > 0 then
  10.         -- Create a selection box on the player
  11.         local selectionBox = Instance.new("SelectionBox")
  12.         selectionBox.Adornee = player.Character
  13.         selectionBox.LineThickness = 0.1
  14.         selectionBox.Parent = player.Character
  15.  
  16.         -- Wait for a short duration to show the selection box
  17.         wait(3)
  18.  
  19.         -- Heal the player
  20.         player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth
  21.  
  22.         -- Remove the selection box
  23.         selectionBox:Destroy()
  24.         Tool.stacks.Value -= 1
  25.     end
  26. end
  27.  
  28. -- Handle equipped event
  29. Tool.Equipped:Connect(function(mouse)
  30.     -- Create a selection box for the local player
  31.     local selectionBox = Instance.new("SelectionBox")
  32.     selectionBox.Adornee = game.Players.LocalPlayer.Character
  33.     selectionBox.LineThickness = 0.1
  34.     selectionBox.Parent = game.Players.LocalPlayer.Character
  35.  
  36.     -- Wait for a short duration to show the selection box
  37.     wait(1)
  38.  
  39.     -- Remove the selection box
  40.     selectionBox:Destroy()
  41. end)
  42.  
  43. -- Handle mouse button click
  44. Tool.Activated:Connect(function()
  45.     -- Check if the player is healing themselves
  46.     local humanoid = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
  47.     if humanoid and humanoid.Health >= number then
  48.         Heal(game.Players.LocalPlayer)
  49.         script.Parent.Handle.healed:Play()
  50.     elseif humanoid and humanoid.Health >= humanoid.MaxHealth then
  51.         Heal(game.Players.LocalPlayer)
  52.         script.Parent.Handle.healed:Play()
  53.  
  54.     end
  55.  
  56.     while wait() do
  57.         if Tool.stacks.Value == 0 then
  58.             Tool:Destroy()
  59.             wait(1)
  60.             break
  61.         end
  62.     end
  63. end)
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement