GUI TextBox Issue

Hello! I have a question. I am fairly new to GUIs and how they work, but I have a bit of experience with scripting itself. The first image is the actual GUI itself, and the second image is the script for it.


However, when I run it, change the text, and click the “Submit” button, it prints out “0” (the already-placed text) no matter what.

Is there any way to make it print what I change the text to? Thanks for the help!

1 Like

You’re using a normal Script which runs on the server and not on the client. On the client, you’re changing the text through the TextBox gui. However, on the server, the TextBox’s text doesn’t change at all due to replication rules. If you want the server to notice the change, you’ll need to use remotes. But that’s not what you want. In this case, you’ll want to use a LocalScript instead that knows what the client is changing. Keep the same code, but put in a LocalScript instead.

2 Likes

Just insert a local script instead then swap the code should work fine. Please hit the solve button :slight_smile:

in addition you can used the changed event like so:

local TextButton = script.Parent.TextButton

TextButton.Changed:Connect(function()
    print(TextButton.Text)
end)

You’d want to print the text of the TextBox, not the TextButton.

1 Like

Thank you! There was just one issue. I wanted to make this a Discord webhook integration (where the webhook would print out what someone typed in the TextBox instead, which wouldn’t work in a LocalScript of course. Is there a workaround for this? I’m just not too familiar with GUI scripting. :slight_smile:

If you’re planning to give a user control of sending webhook requests, you best be limiting it so they cannot spam it (in both the LocalScript and the normal Script). You can use a RemoteEvent that the client fires for the server (RemoteEvent:FireServer("Hello")) which the server can listen to (RemoteEvent.OnServerEvent:Connect(function(player, message)). Be sure to make sanity checks not only as spam checks but also as for example, checking if the value they sent is actually a string (if type(message) == "string" then). Otherwise, errors may appear. As for scripting the webhook request, I’m sure there are a lot of tutorials out already, but of course you can reply again if you happen to get stuck. Though, I have to go now, so hopefully someone else will catch up. Good luck!

1 Like

Thank you so much! I was just about to ask about firing servers right before you sent that. I appreciate all the help!

2 Likes