Advertisement
Sungmingamerpro13

Tool with Stacks (Quantity System)

May 6th, 2024 (edited)
676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 0.64 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.     if Tool:WaitForChild("stacks") and Tool.stacks.Value > 0 then
  14.         Tool.stacks.Value -= 1
  15.     else
  16.         Tool:Destroy()
  17.         QuantityText.Visible = false
  18.     end
  19. end)
  20.  
  21. Tool.Equipped:Connect(function()
  22.     QuantityText.Visible = true
  23. end)
  24.  
  25. Tool.Unequipped:Connect(function()
  26.     QuantityText.Visible = false
  27. end)
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement