Is it possible to remove letters from strings?

2 Likes

can you give me your current script

from the above display is where the numbers are displayed
back is the button you want to click on to delete the last number
are those assumptions correct?

but there are 2 back buttons

3 Likes

Yes sorry for the late response.

local CUR = 0
local CURR = nil
local numberT = {
	["1"] = nil;
	["2"] = nil;
	["3"] = nil;
	["4"] = nil;
	["5"]= nil;
	["6"] = nil;
	["7"]= nil;
	["8"] = nil;
	["9"] = nil;
	["10"] = nil;
}

for _, v in ipairs(script.Parent:GetChildren()) do
	if v:IsA("TextButton") then
		v.MouseButton1Click:Connect(function()
			print(v.Name)
			CUR+=1
			numberT[CUR] = v.Name
			CURR = v.Name
			local finalString = ''

			for index, value in pairs(numberT) do
				finalString ..= tostring(value)
			end

			script.Parent.Parent.DISPLAY.Text = finalString
		end)
	
	end
end
2 Likes
-- literally your entire script
for _, button in script.Parent:GetChildren() do
	if button:IsA("TextButton") then
		button.MouseButton1Click:Connect(function()
			script.Parent.Parent.DISPLAY.Text ..= button.Text
		end)
	end
end

Iā€™d recommend you to place all the relevant buttons under some kind of Input folder. This would avoid errors in the future should you decide to create a new TextButton under the Keypad frame.

P.S. In the original post, you asked for a way to remove the last character from a string, but really you wanted to append them. Please be more specific in the future.

5 Likes

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