Advertisement
Sungmingamerpro13

New ToolScript with Stacks (QuantityText)

Jan 10th, 2025 (edited)
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 0.69 KB | None | 0 0
  1. local Tool = script.Parent
  2.  
  3. local player = game.Players.LocalPlayer
  4. local QuantityText = player.PlayerGui:WaitForChild("BackpackGui").Frame.quantityLabel
  5.  
  6. Tool:WaitForChild("stacks").Changed:Connect(function(value)
  7.     QuantityText.Text = "Quantity: "..value
  8. end)
  9.  
  10. QuantityText.Text = "Quantity: "..Tool.stacks.Value
  11.  
  12. Tool.Activated:Connect(function()
  13.     if Tool:WaitForChild("stacks") and Tool.stacks.Value > 1 then
  14.         Tool.stacks.Value -= 1
  15.         player.Character.Humanoid.Health += 5
  16.     else
  17.         Tool:Destroy()
  18.         QuantityText.Visible = false
  19.     end
  20. end)
  21.  
  22. Tool.Equipped:Connect(function()
  23.     QuantityText.Visible = true
  24. end)
  25.  
  26. Tool.Unequipped:Connect(function()
  27.     QuantityText.Visible = false
  28. end)
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement