How do I get the contents of all text entered in a textbox

In the white box is the textbox, everytime a number is inside the textbox and the player presses enter. I want the number they inputted in the textbox to be displayed in the textlabel, “Previous Guesses:”.

So that part is mostly easy to create, as a matter of fact I have done it. But the problem is when I type in another guess in the textbox and press enter. It replaces my previous guess

Can you post the script you are working with? Are you using an array to store previous guesses?

TextBox.FocusLost:Connect(function(Enter)	
	if Enter == true then -- Checks if EnterKey Is Pressed.
		print("Pressed Enter!")
		
		local TestText = TextBox.Text
		script.Parent.Parent.Parent.Last.Numbers.Text = TestText .. "; "
		
		local Number = tonumber(TextBox.Text)
		if Number then -- checks if the textbox has only numbers if not it will not continue.
			if Number == RandomNum then
				script.Parent.Parent.Answer.ImageTransparency = 0
				script.Parent.Parent.Answer.Image = "rbxassetid://12856690383"
				wait(1.85)
				script.Parent.Parent.Answer.ImageTransparency = 1
				
			else
				script.Parent.Parent.Answer.ImageTransparency = 0
				script.Parent.Parent.Answer.Image = "rbxassetid://12856695110"
				wait(1.85)
				script.Parent.Parent.Answer.ImageTransparency = 1
			end
		end
	end
end)

If Last.Numbers.Text is the previous guesses then you want to concatenate TestText with itself like so

script.Parent.Parent.Parent.Last.Numbers.Text ..= TestText .. "; "

..= will concatenate the string onto itself like += will add a number into a variable.

1 Like

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