[TUTORIAL] Tool Durability

Hello! Today, I’ll teach everybody how to make a Durability System!
Short Answer: Create an IntValue and when it reaches 0, the tool breaks.

– DISCLAIMER: Please understand what I’m doing and not just copy the script.

First, create your tool and add a LocalScript.

In the LocalScript, we have to make the IntValue and set it’s properties.

local value = Instance.new("IntValue") -- Creates the IntValue
value.Parent = game.ReplicatedStorage -- Sets the IntValue's Parent
value.Value = 8 -- Sets how many uses the Tool Has

Now, Let’s make the IntValue Decrease when tool is in hand and it is clicked

tool.Activated:Connect(function() -- When tool pressed
	value.Value -= 1 -- remove 1 from IntValue
end)

Now, let’s remove the tool from player’s backpack (and optionally, let’s Unequip the tool first, so we don’t have any Custom animation problems)

local player = game.Players.LocalPlayer.Character
local Humanoid = player:WaitForChild("Humanoid")
	if value.Value <= 0 then -- if the value is 0 or under
		Humanoid:UnequipTools()
		tool:Destroy() -- Destroy the tool
	end
end)

And for the end, let’s add a debounce so the player doesn’t spam click.

tool.Activated:Connect(function() -- When tool pressed
	if db == false then -- if the function is unlocked
		db = true -- lock the function, so the player doesn't spam
		wait(2) -- how much to wait, configure it how much you want.
		db = false -- unlock the function
	end
end)

The Final (Local)Script will be:

local tool = script.Parent -- tool
local player = game.Players.LocalPlayer.Character
local Humanoid = player:WaitForChild("Humanoid")
local value = Instance.new("IntValue") -- Creates the IntValue
value.Parent = game.ReplicatedStorage -- Sets the IntValue's Parent
value.Value = 8 -- Sets how many uses the Tool Has
db = false -- unlock the function

tool.Activated:Connect(function() -- When tool pressed
	if db == false then -- if the function is unlocked
		db = true -- lock the function, so the player doesn't spam
		value.Value -= 1 -- remove 1 from IntValue
		if value.Value <= 0 then -- if the value is 0 or under
			Humanoid:UnequipTools()
			tool:Destroy() -- Destroy the tool
		end
		wait(2) -- how much to wait, configure it how much you want.
		db = false -- unlock the function
	end
end)
16 Likes

If there’s anything you’d like to know, please reply!

protip: bind a key to start/stop recording in obs to avoid having to show the obs window

6 Likes

Thanks for the tip! I’ll bind a key

1 Like

pro tip the tool will still be there on the server as you’re using a local script instead of a normal script

3 Likes

pro tip use a remote to fire to the server so that when it detects the durability hitting 0 it’ll destroy tool from the server.

2 Likes

pro tip handle durability from the server completely so it isn’t exploitable

2 Likes

Pro tip: you can add a GUI bar with a UDIM2 horizontal size changing script linked with intvalue for cool visuals

3 Likes

anyone with common sense would know not to make it exploitable lmao

1 Like