"Backspace" button? (Deleting last letter in a string/text)

How do i make it so when i click a button i can remove the most recent character/letter in a string/text like a backspace? Ive tried this and it doesnt seem to be working for me. (the gui is a surface gui if this changes anything with an adornee.)

script.Parent.Buttons.Delete.MouseButton1Click:Connect(function()
	local text = tostring(box.Text)
	text = string.sub(text, 1, #text-1)
end)
--box is equal to a textbox.

It looks like you accidentally updated the variable rather than the property.

box.Text = string.sub(text, 1, #text - 1)
2 Likes

this managed to help! thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.