Advertisement
Sungmingamerpro13

MedkitScript (Changed System)

May 6th, 2024
728
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 2.18 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 ChangedText = BackpackFrame.ChangedText
  7.  
  8. Tool:WaitForChild("stacks").Changed:Connect(function(Value)
  9.     ChangedText.Text = "Changed: "..Value
  10. end)
  11.  
  12. ChangedText.Text = "Changed: "..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.     ChangedText.Visible = true
  39.    
  40.     -- Create a selection box for the local player
  41.     local selectionBox = Instance.new("SelectionBox")
  42.     selectionBox.Adornee = game.Players.LocalPlayer.Character
  43.     selectionBox.LineThickness = 0.1
  44.     selectionBox.Parent = game.Players.LocalPlayer.Character
  45.  
  46.     -- Wait for a short duration to show the selection box
  47.     wait(1)
  48.  
  49.     -- Remove the selection box
  50.     selectionBox:Destroy()
  51. end)
  52.  
  53. Tool.Unequipped:Connect(function()
  54.     ChangedText.Visible = false
  55.  
  56. end)
  57.  
  58. -- Handle mouse button click
  59. Tool.Activated:Connect(function()
  60.     -- Check if the player is healing themselves
  61.     local humanoid = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
  62.     if humanoid and humanoid.Health >= number then
  63.         Heal(game.Players.LocalPlayer)
  64.         script.Parent.Handle.healed:Play()
  65.     elseif humanoid and humanoid.Health >= humanoid.MaxHealth then
  66.         Heal(game.Players.LocalPlayer)
  67.         script.Parent.Handle.healed:Play()
  68.        
  69.     end
  70.    
  71.     while wait() do
  72.         if Tool.stacks.Value == 0 then
  73.             Tool:Destroy()
  74.             ChangedText.Visible = false
  75.             wait(1)
  76.             break
  77.         end
  78.     end
  79. end)
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement