Advertisement
Sungmingamerpro13

MedkitScript 2 (Quantity System)

May 6th, 2024 (edited)
640
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 2.19 KB | None | 0 0
  1. local Tool = script.Parent
  2. local number = 0
  3.  
  4. local player = game.Players.LocalPlayer
  5. local BackpackFrame = player.PlayerGui:WaitForChild("BackpackGui").Frame
  6. local QuantityText = BackpackFrame.QuantityText
  7.  
  8. Tool:WaitForChild("stacks").Changed:Connect(function(value)
  9.     QuantityText.Text = "Quantity: "..value
  10. end)
  11.  
  12. QuantityText.Text = "Quantity: "..Tool.stacks.Value
  13.  
  14. -- Create the Heal function
  15. local function Heal(player)
  16.     -- Check if the player is alive
  17.     if player.Character and player.Character:FindFirstChild("Humanoid") and player.Character.Humanoid.Health > 0 then
  18.         -- Create a selection box on the player
  19.         local selectionBox = Instance.new("SelectionBox")
  20.         selectionBox.Adornee = player.Character
  21.         selectionBox.LineThickness = 0.1
  22.         selectionBox.Parent = player.Character
  23.  
  24.         -- Wait for a short duration to show the selection box
  25.         wait(3)
  26.  
  27.         -- Heal the player
  28.         player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth
  29.  
  30.         -- Remove the selection box
  31.         selectionBox:Destroy()
  32.         Tool.stacks.Value -= 1
  33.     end
  34. end
  35.  
  36. -- Handle equipped event
  37. Tool.Equipped:Connect(function(mouse)
  38.     QuantityText.Visible = true
  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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement