Hello! I made a script that needs to check if a TextBox’s Text and number are the same. My goal is to get make it so when a character is typed, a script gets notified and changes the Text in the properties tab to be what is typed.
Problem: However, when you type or click off the box, the Text section is properties doesn’t change. While there are solutions like this one, these don’t seem to work on a SurfaceGUI, but rather a screenGUI.
’Attempts’: So far, I’ve tried adding a script under the TextBox with scripts in the previously linked problem, but I haven’t gotten anything to work yet.
Is there a certain GetPropertyChangedSignal for SurfaceGUIs that I haven’t discovered?
local MyRemoteEvent = game.ReplicatedStorage.MyRemoteEvent
local MyTextBox = script.Parent
MyTextBox:GetPropertyChangedSignal("Text"):Connect(function(txt)
MyRemoteEvent:FireServer(txt)
end)
ServerScript
local MyRemoteEvent = game.ReplicatedStorage.MyRemoteEvent
local MySurfaceGuiTextLabel = --Put your stuff here
MyRemoteEvent.OnServerEvent:Connect(function(PlayerWhoSent, TextThatWasSent)
MySurfaceGuiTextLabel.Text = TextThatWasSent .. " -" .. PlayerWhoSent.Name --If I sent "Hello", it would make it "Hello -Benpinpop"
end)
Hello!
I’m trying to use this for a small project I’m working on, but I keep getting one error I don’t know how to resolve.
It says:
“Unable to assign property Text. string expected, got Instance”
I modified the scripts a little, so I’m going to show them because I don’t know if that’s causing the problem. The local script
local MyRemoteEvent = game.ReplicatedStorage.MyRemoteEvent
local MyTextBox = script.Parent
MyTextBox:GetPropertyChangedSignal("Text"):Connect(function(txt)
MyRemoteEvent:FireServer(txt)
end)
The server script
local MyRemoteEvent = game.ReplicatedStorage.MyRemoteEvent
local MySurfaceGuiTextLabel = game.Workspace.P2.Table2.Sign.SurfaceGui.SIGN
MyRemoteEvent.OnServerEvent:Connect(function(TextThatWasSent)
MySurfaceGuiTextLabel.Text = TextThatWasSent
end)
If I need to show anything else, just tell me and I will.
Thank you in advance!
Your issue is that you are passing txt within the local script as a parameter, where in fact, Instance:GetPropertyChangedSignal does not pass a parameter when it’s fired. Change “txt” when you fire the server to just be MyTextBox.Text and you should be good.