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)

2 comments
Use RemoteEvents in ReplicatedStorage, scripts for RemoteEvents in Workpsace or ServerScriptService.
Also don't forget to use FilterStringAsync either, it won't error in testing mode but if you don't filter it, Roblox will disable the place till you fix it. It basically filters the text to make sure it's safe for users to see/read. Here is a link to the wiki about it, https://developer.roblox.com/articles/Text-and-Chat-Filtering