I have a text box that I want people to enter their text in. After they press enter, it is supposed to press enter and fire a remote event. The text should then be printed into the output, but it prints nil instead of what the player entered. How would I fix this? By the way: This is on a surface GUI. Here is my button script:
script.Parent.MouseButton1Click:Connect(function() local text = script.Parent.Parent.TextBox.Text game.Workspace.Events.Text:FireServer(text) end)
Here is my print script:
script.Text.OnServerEvent:connect(function(plr, text) print(text.Value) end)
localscript
script.Parent.MouseButton1Click:Connect(function() local text = script.Parent.Parent.TextBox.Text game.Workspace.Events.Text:FireServer(text) -- fire the textbox's Text in the 2nd arg end)
serverscript
script.Text.OnServerEvent:Connect(function(plr, text) -- use Connect not connect print(text) -- prints the text end)
text doesn't have a value
I suggest you rubber duck your code. Say it out loud, line by line. You're listening to a different event than what you're firing.