local newID = tostring(script.Parent.Text)
local subbedID = newID:sub(1,-2)
subbedID = newID.."2"
subbedID = tostring(subbedID)
print(newID.." is the old id, "..subbedID)
and my goal is to set the subbedID variable to newID without the last character of the string and replace it with 2. I have been searching the devForum and other sites, and found that I should use string:sub, so I tried the above code. However it doesn’t remove the last character of the string, it just adds 2 to it. Any ideas?
local textbox = script.Parent
local newID = textbox.Text
local subbedID = newID:sub(1,-2)
subbedID = subbedID..2
print(newID.." is the old id, "..subbedID)
You don’t need to be calling tostring() as the value assigned to the “Text” property of GuiObject instances is a string value anyway. The previous post provided the correct solution, you should be concatenating “2” to the new string not the old string.