Advertisement
Sungmingamerpro13

New ToolScript with QuantityText 2 (LocalScript)

Feb 28th, 2025
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.36 KB | None | 0 0
  1. local Tool = script.Parent;
  2.  
  3. local player = game.Players.LocalPlayer
  4. local QuantityLabel = player.PlayerGui:WaitForChild("QuantityGui").quantityLabel
  5.  
  6. enabled = true
  7.  
  8. function onActivated()
  9.     if not enabled  then
  10.         return
  11.     end
  12.  
  13.     enabled = false
  14.  
  15.     wait(.8)
  16.  
  17.     local Humanoid = player.Character:FindFirstChild("Humanoid")
  18.     local EatAnimation = Humanoid:LoadAnimation(script.Parent.EatAnimation)
  19.    
  20.     if (Humanoid ~= nil) then
  21.         if (Humanoid.MaxHealth > Humanoid.Health + 1.6) then
  22.             Humanoid.Health = Humanoid.Health + 1.6
  23.         else   
  24.             if Humanoid.Health == Humanoid.MaxHealth then
  25.                 if Tool:WaitForChild("stacks") and Tool.stacks.Value > 1 then
  26.                     print(Tool.Name.." ("..Tool.stacks.Value..")")
  27.                    
  28.                     Tool.stacks.Value = Tool.stacks.Value - 1
  29.                     script.Parent.heal:Play()
  30.                     EatAnimation:Play()
  31.                 else
  32.                     Tool:Destroy()
  33.                     QuantityLabel.Visible = false
  34.                 end
  35.             end
  36.         end
  37.     end
  38.  
  39.     enabled = true
  40.  
  41. end
  42.  
  43. Tool:WaitForChild("stacks").Changed:Connect(function(Value)
  44.     QuantityLabel.Text = "Quantity: "..Value
  45. end)
  46. QuantityLabel.Text = "Quantity: "..Tool.stacks.Value
  47.  
  48. script.Parent.Activated:connect(onActivated)
  49.  
  50. script.Parent.Equipped:Connect(function()
  51.     QuantityLabel.Visible = true
  52.     QuantityLabel.Text = "Quantity: "..Tool.stacks.Value
  53. end)
  54.  
  55. script.Parent.Unequipped:Connect(function()
  56.     QuantityLabel.Visible = false
  57. end)
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement