✓ Accepted answer
Although you're LocalScript in order to use the TextBox, the Https Service is only accessed on the Server, (A TextBox will also not work with MouseButton1Click or Activated, thus you'll need a Button) so you will need a Script in Server Script Service, a LocalScript in StarterGUI, and a Remote Event in Replicated Storage. Here is an example for the line of code:
Server Script
local webhook = "https://discordapp.com/api/webhooks/0"
local remote = game.ReplicatedStorage.FilteringFunction
local HTTP = game:GetService("HttpService")
function Fire(player, msg)
local payload = HTTP:JSONEncode({
content = msg,
username = player.Name.." - (#"..player.UserId..")"
})
HTTP:PostAsync(webhook, payload)
end
remote.OnServerEvent:Connect(Fire)
LocalScript
local remote = game.ReplicatedStorage.FilteringFunction
function Send()
local msg = script.Parent.TextBox.Text
remote:FireServer(msg)
end
script.Parent.TextButton.Activated:Connect(Send)
My Remote Event for this is named "FilteringFunction". The placement of the LocalScript in this scenario is under a ScreenGui, with both a TextBox and a TextButton also under the Gui.
2 comments
Please censor your webhook url - there might be some people who will spam messages with the webhook
Oh god, thank you. That would have been bad.