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
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
--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.
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