CCCPaste

Tool with Stacks (Quantity System)

local Tool = script.Parent

local player = game.Players.LocalPlayer
local QuantityText = player.PlayerGui:WaitForChild("QuantityGui").QuantityText

Tool:WaitForChild("stacks").Changed:Connect(function(value)
	QuantityText.Text = "Quantity: "..value
end)

QuantityText.Text = "Quantity: "..Tool.stacks.Value

Tool.Activated:Connect(function()
	if Tool:WaitForChild("stacks") and Tool.stacks.Value > 0 then
		Tool.stacks.Value -= 1
	else
		Tool:Destroy()
		QuantityText.Visible = false
	end
end)

Tool.Equipped:Connect(function()
	QuantityText.Visible = true
end)

Tool.Unequipped:Connect(function()
	QuantityText.Visible = false
end)