Text box text to surface gui

I want a text box so when you write in it, the text you put in will show up on a surface gui to everyone. I have attempted this but all scripts failed.

           while true do 
    	wait(1)
    	script.Parent.Text = game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.Text
    end
4 Likes

We don’t hand out free scripts here. If you already attempted it, show us what you did and we can correct what you did wrong or didn’t do.

1 Like

Alright, here. ( this was a normal script inside a text label, which of course was in a surface gui )

while true do 
	wait(1)
	script.Parent.Text = game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.Text
end

Dude can you at least give him some support or describe how to do it?

6 Likes

Since this is a normal script on the server / workspace, you cannot get the local player since there is no local player. Server applies to everyone, not a single player. You would need to change that to a specifics players name or another method that applies to your game.

 game.Players.LocalPlayer.PlayerGui
--change to 
game.Players["Builderman"].PlayerGui

You could pass a Changed event of a :GetPropertyChangedSignal event for the textbox in the PlayerGui (Make sure this is used in a local script, not a server side script). In the event, you can fire a Remote event filtering text script on the server so the player doesn’t type anything inappropriate. It will then filter the text and make the surface GUI visible to everybody by setting the surface GUI text to the filtered text. If you need a little demo of how this would look, I would love to help you out :slight_smile:

I already tried that! It didn’t work at all.

Did you get any errors?..

No. I didn’t get any errors at all.

Maybe you didn’t write it effectively. I did exactly what I said and it worked just fine?

1 Like

Hmm. I am not sure, if you can give me your script there might be something different. but I did what you said!

This is the local script for the textbox:

--Be sure to create your own variables for the Textbox and the Remote Event!!
TextBox.Changed:Connect(function()
	RemoteEvent:FireServer(TextBox.Text)
end)

For the server retrieval:

RemoteEventOnServerEvent:Connect(function(Player, Text)
	SurfaceGUITextLabel.Text = Text
end)

I didn’t include the text filtering because it would just be unnecessary as you could look it up on your own time, but this is just the main concept.

4 Likes

Wait, is this text visible to everyone inside the game?

It shows for everybody on the server.

Okay… I will look at my script real quick and see what happened.

hmmm, I think I forgot the remoteEvent. that would damage the script…

My only question is, the other part of the script, the server retrieval, It must be a server script right? so everyone can see.

Correct. The server allows everybody in the game to see what you are passing. That is why it is very important to limit the amount of data being sent from the Client to the Server to prevent exploitation

well… Okay. I will probably spend a few hours trying to figure out the variables… Im not good at that kind of stuff.

This can be solved with the FocusLost. There is an example script in there. Please edit that script accordingly with your game