Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I get text from a TextBox to the current server?

I have a problem when a local player enters something in the TextBox, the current client shows, but the current server shows nothing. How can I change it?

1 answer

✓ Accepted answer

That happens because everything that happens ClientSide stays on the Client's Side unless you communicate it to the Server.

I recommend reading more into Server to Client-side communication Here. In order to have it update to the Server, you need to send the Text trough a RemoteEvent and have a Server Script update all the other Client's TextBoxes using the FireAllClients() function for RemoteEvents

Then after sending the Text to the Client's, you would need to update the Text of the TextBox on the Client's Side.

Here's an example; In order for this to work, you need to place a RemoteEvent inside the ReplicatedStorage. I named it "UpdateTextBox", but you can name it whatever you like.

Client Side:

--Client (LocalScript inside the GUI)
script.Parent.TextBox.Changed:Connect(function()
game:GetService("ReplicatedStorage").UpdateTextBox:FireServer(script.Parent.TextBox.Text)
end)

So everytime a Player types in the TextBox, it updates it. And when it updates, we fire a RemoteEvent, thus sending the Text to the Server.

Server Side:

--Server (Script inside ServerScriptService)
game:GetService("ReplicatedStorage").UpdateTextBox.OnServerEvent:Connect(function(Player,Text)
-- You should add a text filter check before displaying the Text to other Players
game:GetService("ReplicatedStorage").UpdateTextBox:FireAllClients(Text)
end)

Once we recive the Text, it would be a good idea to filter it to remove any no-no words. Then we send the Text to all the the Clients.

Back on Client Side:

--Final Client Script:
script.Parent.TextBox.Changed:Connect(function()
game:GetService("ReplicatedStorage").UpdateTextBox:FireServer(script.Parent.TextBox.Text)
end)

game:GetService("ReplicatedStorage").UpdateTextBox.OnClientEvent:Connect(function(Text)
script.Parent.TextBox.Text = Text -- Displaying Text
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.