local prevText = ""
checkinProgress.userSelection.textBox.TextBox.Changed:Connect(function()
if db2 == false then
if prevText ~= checkinProgress.userSelection.textBox.TextBox.Text then
local customer = getPlr(checkinProgress.userSelection.textBox.TextBox.Text)
prevText = checkinProgress.userSelection.textBox.TextBox.Text
print(prevText)
print(checkinProgress.userSelection.textBox.TextBox.Text)
db2 = true
------ Script continues
db2 = false
end
end
end
This is what happens, this order
I type: a
PrevText: a
TextBox.Text: a
I type: av (have a function to set the capital to match the player’s name) so it turns in Av
PrevText: av
TextBox.Text: av
I type: Avi
print(PrevText): Av
print(TextBox.Text): Av
I type: Avio
print(PrevText): Avi
print(TextBox.Text): Avi
You get the idea, from there it falls one behind
I have no idea why it’s doing this
You are getting the same printout because you set prevText to what the TextBox currently says before printing it. You should print(prevText)
before setting prevText
.
That’s not my problem, prevText is just to limit the .Changed event, it checks if the text that was before = the one now, if not it continues.
The problem is that heckinProgress.userSelection.textBox.TextBox.Text seems to be off from the actual text. I’m typing avio and it only says av or avi. When I start deleting the text it goes to where I typed and then starts clearing the text, always with a ~2/3 character delay. That’s my issue
Instead of using Instance.Changed
, use Instance:GetPropertyChangedSignal()
, it will only fire on the property you want, instead of all properties, that way, you don’t need to check if the property is the property you are looking for.
local previousText = ""
checkinProgress.userSelection.textBox.TextBox:GetPropertyChangedSignal("Text"):Connect(function()
print(previousText)
local newText = checkinProgress.userSelection.textBox.TextBox.Text
print(newText)
previousText = newText
end)
As for your problem, I don’t see any mistakes in your code.
1 Like
Does that fire as you type or just when you unfocus the textBox? Because I need it to update as I type
It fires as you type, so, it would work