I’m trying to make a delete button that can remove a number from the end of a string
My current script:
if #NumbersTyped.Text >= 1 then
local NumberToRemove = string.sub(NumbersTyped.Text,-1,-1)
NumbersTyped.Text = string.gsub(NumbersTyped.Text,NumberToRemove,"",1)
end
My problem: It doesn’t delete from the end
If I type in a number like “4545” it becomes “4 45”
This is one operation too many. Why not just do this?
if #NumbersTyped.Text >= 1 then
-- the start is the first character, then includes all characters until the second last character
-- one character left in the string results in empty string, lol
NumbersTyped.Text = string.sub(NumbersTyped.Text, 1, -2)
end
I tried that it doesn’t delete the number from the string
Oh my bad I read it wrong, thanks it works!!!
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.