Advertisement
Sungmingamerpro13

MedkitScript (Quantity System)

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