Help with code! More of a question about code

So I wanna make a terminal like thing for a upcoming game I am making BUT I do not want say text like this Screen Shot 2021-11-11 at 11.07.21 AM
to be deletable how would I do that without it being weird like I don’t want it to be type able there like my preview code let me do

local frame = script.Parent
local MainText = frame.MainText

while true do
	local stringLength = string.len(MainText.Text)
	wait(0.5)
	while true do
		wait(0.005)
		if stringLength <= 56 or 55 then
			MainText.Text = [[Last Login: the other day 
admin@constructionComputer ~ % ]]
		end
		
	end
end

?
Another thing is how do I make it so enter creates a new line with Screen Shot 2021-11-11 at 11.07.21 AM at the beginning and so you cannot go back up a line and stuff.

1 Like

Watch the textbox for a change in its text and if the text doesn’t have the preface then overwrite it.

local textbox = script.Parent

local preface = "admin@constructionComputer ~ % "

textbox.Text = preface

textbox:GetPropertyChangedSignal("Text"):Connect(function()
	if textbox.Text:sub(1,#preface) ~= preface then
		textbox.Text = preface
	end
	textbox.CursorPosition = math.max(#preface+1, textbox.CursorPosition)
end)

Here is some example code that I think should satisfy what youre trying to do.

2 Likes

TYSM and another thing how do I make it so enter creates a new line? you don’t need to give me code for it

1 Like

I havent tested this however Im pretty sure hitting enter would cause you to lose focus so you would need to refocus back on it. You could enable rich text and add \n to the end of the string to create a new line. In order to prevent the user from deleting anything already written you would probably need to add to the preface each time they do hit enter.

2 Likes

So would I have to grab the user inputs???

1 Like

Screen Shot 2021-11-11 at 12.19.51 PM
also how do I make the text not go off the screen? like out of the text box NVM

1 Like

https://developer.roblox.com/en-us/api-reference/function/TextBox/CaptureFocus
https://developer.roblox.com/en-us/api-reference/event/TextBox/FocusLost

You can use these to detect and force focus changes

2 Likes

You would most likely need to enable the text wrapped property

2 Likes

Wdym how do I use that to make new lines? OHHHH wait I might get it can you explain a little

Set the TextEditable and ClearTextOnFocus properties to false.

1 Like