Advertisement
Sungmingamerpro13

Tool with Stacks (Quantity System)

May 6th, 2024 (edited)
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 0.65 KB | None | 0 0
  1. local Tool = script.Parent
  2.  
  3. local player = game.Players.LocalPlayer
  4. local QuantityText = player.PlayerGui:WaitForChild("QuantityGui").QuantityText
  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.     Tool.stacks.Value -= 1
  14.  
  15.     if Tool.stacks.Value == 0 then
  16.         Tool:Destroy()
  17.         player.Character.Humanoid.Health += 5
  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.  
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement