Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

TextBox Tab Button just creates a space, and not a Tab Space?

I'm trying to make an script editor but when I press the Tab Button it just creates a space (ASCII 32). It should create a Tab space (ASCII 09), but it doesn't. I've tried to script this:

local uis = game:GetService("UserInputService")
local textbox = script.Parent
uis.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.Tab then
		print(textbox.CursorPosition)
		local s1 = string.sub(textbox.Text, 1, textbox.CursorPosition - 1)
		local s2 = "	"	
		local s3 = string.sub(textbox.Text, textbox.CursorPosition, string.len(textbox.Text))

		textbox.Text = s1..s2..s3
	end
end)

the string called s2 just makes a space. I changed the string to random letters and it works, but not with Tab spaces. What can I do?

2 comments

0

I don't think Roblox allows that character. Also, inside s2, is that a tab space or just like 5 normal spaces? Because if it's a tab space then Roblox just might not be able to use that character.

0

its a tab space

1 answer

try \t

odds are when a character doesn’t work, there is an escaped version for it.

here’s a list

2 comments

0

where i can use it? i dont really understand. ive never been good at formating strings

0

replace s2 on line 7 with \t. it transforms into a tab. backslashes plus another character are often transformed into special characters, this is called escaping.

This discussion is preserved as it was. New answers, comments, and votes are closed.