How would I detect when the player changes the text inside a TextBox?

I’m simply trying to detect when the text inside of a TextBox is changed by a player.

I’ve tried using TextBox:GetPropertyChangedSignal("Text") but since I have to modify the text after it’s written, the event gets fired again creating an infinite loop (which stops after 6 attempts because of this error).

image

I don’t know what else to use besides TextBox.InputBegan, but I’d rather not use that because I’d have to create a massive list of Enum KeyCode values to check if the Input is a letter being pressed

2 Likes

You can have two variables - one that saves the previous text and one that stores the current text.

local textBox = script.Parent

local previousText = textBox.Text
local currentText = textBox.Text

while task.wait(3) do
	local currentText = textBox.Text
	if currentText ~= previousText then
		print('Change')
		print('Previous - '..previousText)
		print('Current - '..currentText)
	end
	previousText = currentText
end
1 Like