Print returns Blank (No Text) when there is text on TextBox?

Hello.

I want to figure out why the print on my code returns blank when I try to print the text of a TextBox.

You see, I am making a trainer card and an option to give yourself a name. And that’s another problem. I need a filter for typing in the TextBox.

I created a TextBox. You could type anything you want that isn’t inappropiate. You set it as your Trainer Nickname.

I had a button where it confirms your nickname. When you click the button, it has a remoteEvent and Fires to Server.

On the serverscript, I put a print just to test if it would actually have the player’s nickname printed into the output. Except, it returned as blank. The textbox’s original text was Blank. I think it printed the textbox’s text before the textbox’s text was changed.

I want to know how to fix that.

Here are the scripts:

Local Script:

script.Parent.MouseButton1Down:Connect(function()
	local TxtBox = game.Players.LocalPlayer.PlayerGui.TrainerCard.TrainerFrame.TypeName
	game.ReplicatedStorage.PutName:FireServer(TxtBox)
end)

Server Script:

game.ReplicatedStorage.PutName.OnServerEvent:Connect(function(player, TxtBox)
		player.PlayerGui.TrainerCard.TrainerFrame.Visible = false
		wait(2)
		print(TxtBox.Text)
	end)

Thank you!

1 Like

because your sending the instance over, the instance of the gui has text on the local side but not the server thats why its blank. Maybe send the string not the instance

local script

script.Parent.MouseButton1Down:Connect(function()
	local TxtBox = game.Players.LocalPlayer.PlayerGui.TrainerCard.TrainerFrame.TypeName.Text
	game.ReplicatedStorage.PutName:FireServer(TxtBox)
end)

server script

game.ReplicatedStorage.PutName.OnServerEvent:Connect(function(player, TxtBox)
		player.PlayerGui.TrainerCard.TrainerFrame.Visible = false
		wait(2)
		print(TxtBox)
	end)

It just prints out the name of the textbox

im pretty sure that should be working
(remember to add .Text to the end on the local script)

TrainerFrame.TypeName.Text

Its not working. Txtbox is the actual textbox, not the textbox’s text. I am not that dumb to print the text of a text.

Local

local player = game:GetService("Players").LocalPlayer
script.Parent.MouseButton1Down:Connect(function()
	local TxtBox = player.PlayerGui.TrainerCard.TrainerFrame.TypeName.Text
	player.PlayerGui.TrainerCard.TrainerFrame.Visible = false
	game.ReplicatedStorage.PutName:FireServer(TxtBox.Text)
end)

server

game.ReplicatedStorage.PutName.OnServerEvent:Connect(function(player, text)
	print(text)
end)
2 Likes

why are you sending the entire instance over the reason why its printing blank is because your changing the text on the client and then when you send it over the server checks that text box and since text boxes dont replicate on the server it reads as nothing. send the TextBox.Text not the instance

since your genius, why did it print the textbox’s name?

local TxtBox = game.Players.LocalPlayer.PlayerGui.TrainerCard.TrainerFrame.TypeName

Is game.Players.LocalPlayer.PlayerGui.TrainerCard Class name “ScreenGui”?

is the text boxes name TypeName?

yes, why???

Yessir!!!443r3r34r3r

That is because the text is not replicated to the server (when changed by the client).
Send the text to the server instead, not the button itself.

1 Like

bruh smart. How am i so dumb???

1 Like

It’s just something people don’t realize in time.
You can look more into replication here: Working with the Replication Boundary

does it print like this?
anything

Ghost solved it. Now the print shows what the text of the textbox is. Thank you very much for trying!

1 Like

F.Y.I: This was the shortest solved forum I’ve ever seen

No worries.
I still recommend you to learn more about replication though, it’s a good thing to have.

Wait, how do I filter it though so that they dont put their nicknames as bad words?