To send text from a local script (GUI) to a server script, you need to use remote events for sure.
Local script:
You can use these remote events by making a remote event in replicated storage and naming it whatever you like. You need to remember it for the future.
Next, in the local script, you MUST fire the remote event to the server.
script.Parent.MouseButton1Click:Connect(function()
if debounce == false then
debounce = true
local text = script.Parent.Text -- Change this to the location of the text box
game.ReplicatedStorage.<REMOTE-EVENT-NAME>:FireServer(text)
end
end)
Server script:
The server script can be placed inside of ServerScriptService or inside a part that requires this remote event to function.
Here is what you should write inside the server script:
game.ReplicatedStorage.<REMOTE-EVENT-NAME>.OnServerEvent:Connect(function(Player, text) -- By default, you should have "player" as that is the first parameter and it won't function without it.
-- Your code here
end)
Conclusion:
Errors
If there are any errors, report them here! Make sure to show the console.
Debugging
If there are no errors, add some print()
codes in the script to see where it stops.
Hope this helps!