Is it possible to add plus one to a attribute each time you activate a tool? [SOLVED]

I was wondering if it was possible to add one number to a attribute each time you use a tool. I try to do this but I can’t because of this red error underline the plus:
Screenshot 2022-08-28 214001

Is this possible?


local Tool = script.Parent
local IncreaseNumber = 0

Tool.Activated:Connect(function()
	local Character = Tool.Parent
	Character:SetAttribute("Test", IncreaseNumber)
	IncreaseNumber += 1
end)

You can so something like this, The “IncreaseNumber” will go up every time the tool is being used

1 Like

On occasions where you don’t want to pollute the namespace you can do the following.

Character:SetAttribute("Value", (Character:GetAttribute("Value") or 0) + 1)
3 Likes