CCCPaste

Tool With Stacks (Tool Stacks System)

local Tool = script.Parent

local player = game.Players.LocalPlayer
local ChangedText = player.PlayerGui:WaitForChild("BackpackGui").Frame.ChangedText

local number = 5

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

ChangedText.Text = "Changed: "..Tool.stacks.Value

Tool.Activated:Connect(function()
	Tool.stacks.Value -= 1

	if Tool.stacks.Value == 0 then
		player.Character.Humanoid.Health += number
		Tool:Destroy()
		ChangedText.Visible = false
	end
end)

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

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