Why doesn't 'GetPropertyChangedSignal' work correctly?

I have frankly no idea why this doesn’t work, I seem to be doing everything right, and when placed in another script it works, but in this particular script it doesn’t.

I have a ScreenGui, and the children are a LocalScript and a TextBox. I want to use the ‘GetPropertyChangedSignal’ event to get the text of the TextBox everytime it’s changed, but for some reason it doesn’t work at all and I have no idea why. Below is a picture of how they’re positioned.

https://gyazo.com/99fc5b7bea0e8f4c402ce15fc80be8f6

ALL IN A LOCAL SCRIPT

Here is the code that I have been using:

local EnterWords = script.Parent.EnterWords

EnterWords:GetPropertyChangedSignal("Text"):Connect(function()
	print(EnterWords.Text)
end)

I can’t tell whether I’m making a simple mistake because I can’t see why this won’t work. I will accept your answer if it works.

Edit: Even if I do:

print(game.Players.RyanTheLion911.PlayerGui.randomWords.EnterWords.Text)

nothing prints out, even though the TextBox has text.

Edit: I have a feeling the issue may be with getting the ‘EnterText’ variable, but I don’t see why I wouldn’t be getting an error in the log.

2 Likes

It will print nothing because it’s clientsided, and it’s not going to work, because it’s text, the text applies when it’s finished not when it’s being printed.

I already had preset text of ‘Hello’, however, this doesn’t print.

I just reproduced your problem down to the instance names and source code, and I couldn’t find anything wrong with it?

  • Try printing something you know would work without using the textbox at all, like print("SCRIPT WORKING")
  • You could also try doing something other than printing when the text changes, like changing the text box’s position/size

The preset value won’t be printed, the Changed signal only fires if the Text property changes after you have connected to the signal. The preset value is already set so it won’t be printed.

The standard pattern is something like this if you want to fire a function with the initial value too.

local EnterWords = script.Parent.EnterWords

local function onEnterWordsChanged()
	print(EnterWords.Text)
end

EnterWords:GetPropertyChangedSignal("Text"):Connect(onEnterWordsChanged)
onEnterWordsChanged() -- call the function so initial value is printed
5 Likes

Sorry I didn’t reply, I went offline. However, even after trying this it still didn’t work, I have no idea why. This is why I am debating whether it is a bug because when I put this exact code with the script being a child of the TextBox, it works perfectly. Also, I tried using the :Changed event instead but the only thing that it did was just print three or four times.

1 Like