I don’t understand how would I make “Text” property change when there has been an edit on the Text box. For example, I want the property to become the same text that is displayed for the player after he is done making an input inside of textbox. I found out about GetPropertChangedSignal()
but I still I don’t quite understand if there is an actual property for displayed text.
Just setting TextLabel.Text to TextBox.Text should work.
Code snippet:
local TextBox = script.Parent:WaitForChild("TextBox")
local TextLabel = script.Parent:WaitForChild("TextLabel")
local function changeText()
TextLabel.Text = TextBox.Text
end
TextBox:GetPropertyChangedSignal("Text"):Connect(changeText)
That is not really what I am trying to achieve, I was wondering if it is possible to do without using extra labels.
So sorry, I really don’t understand.
What are you trying to do?
Edit: Ohh like replace TextBox.Text with some placeholder text after it’s not being typed in anymore?
Like this?
local TextBox = script.Parent
TextBox.FocusLost:Connect(function()
TextBox.Text = "I love you Peng <3"
end)
Well yeah, but I don’t want the text to be premade, I want to put the text that the player has put in textbox. If I am not wrong, on server side the text property does not change when player has interacted with text box, but on client side it does. So I was wondering if it was possible to change the property straight on server side without remote events.
Not placeholder text. Lets say I have a textbox, it has a “5” as a text property set through studio. When trying in game to change the text to “10”, “10” is displayed, and on client side the text property is changed to “10”, but on server side it does not, and the property is still “5”.
Sorry but not to my knowledge.
you can just use a remoteevent to send info other to the sever that just has the text in it basicly
local Box = script.Parent
local TextEvent = game:Getservice("Replicated storage").TextEvent
local function SendTextToSever()
TextEvent:FireSever(box.Text)
end
TextBox:GetPropertyChangedSignal("Text"):Connect(changeText)
this should work
– edit don’t spam alot of remote events if you do that use unreliable remote events
I guess there really is no way to do what I am trying to achieve without remote events. That is quite sad
well if the sever can’t see the changes made on the client then the easy and simplest way to commentate between the client the sever is using a remote event or a unreliable remote even
adding to others have said
you can use the TextBox.FocusLost property if you want to send the remote once the player presses enter or when he leaves the text box
you should also add a limit on the client on how much the sent text can be to prevent the clients from sending very long strings and server checks for the string length before replicating it to other clients
and if the text is going to become very long you can use the
buffer library when sending the string
Edit: unreliable remotes are not good for this because well they are unreliable
Oh I know the rest of things that you just said, and don’t worry, I will not let the string be bigger than 3 characters.
I am having slight issues:
LocalScript:
local players = game.Players
local player = players.LocalPlayer
local textBox = script.Parent
local text = textBox.ContentText
local event = game.ReplicatedStorage.Events.GetTextZ
local function SendText()
event:FireServer(text)
end
textBox:GetPropertyChangedSignal("ContentText"):Connect(SendText())
ServerScript:
local textBox = script.Parent
local event = game.ReplicatedStorage.Events.GetTextZ
local function changeText(player, text)
textBox.Text = text
end
event.OnServerEvent:Connect(changeText)
Sadly it does not work. Both scripts are inside of the textBox.
@hinkalka230
with :Connect you have to call the function by reference which can be done by removing the ( )
do
textBox:GetPropertyChangedSignal("ContentText"):Connect(SendText)
instead of
textBox:GetPropertyChangedSignal("ContentText"):Connect(SendText())
also change the function to this
local function SendText()
event:FireServer(textBox.ContentText)
end
because the text variable will not change if content text is changed
Ill try that, and then answer back in a few minutes
Didn’t help still.
limitations
I guess that the server script is in StarterGui
maybe try changing the server script run context to “Server” ?
Unfortunately, did not work either. Before it was legacy, by the way.
I don’t really know how to fix this issue, someone else may see this topic and try to help