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