Advertisement
Sungmingamerpro13

Tool with Stacks (Quantity System)

May 6th, 2024 (edited)
657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 0.70 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.     while wait() do
  16.         if Tool.stacks.Value == 0 then
  17.             Tool:Destroy()
  18.             player.Character.Humanoid.Health += 5
  19.             QuantityText.Visible = false
  20.             wait(1)
  21.             break
  22.         end
  23.     end
  24. end)
  25.  
  26. Tool.Equipped:Connect(function()
  27.     QuantityText.Visible = true
  28. end)
  29.  
  30. Tool.Unequipped:Connect(function()
  31.     QuantityText.Visible = false
  32. end)
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement