I’m making a system where if you have more then one of the same item the name of the item becomes (ToolName)_(Amount of the same tool in the inventory) for example Axe_1.
I want to remove the _1 at the end of the tool’s name without removing any character from the tool’s name.
I tried string.sub(Tool.Name,1,string.len(Tool.Name) - 2) and it works if the Amount of items is less then 9 but it wouldn’t delete the full thing if for example I had Axe_10. Is there a better way to do it?
local function itemtitle(item, amount)
local name = item.Name:split("_")[1]
if amount == 1 then
return name
elseif amount <= 0 then
return false
else
return name .. " (x"..amount..")"
end
end
No my question was how I could remove _(Number of items) regardless of the number since if it has more then 1 digit then it would keep the _ in the tool’s name