Help With Webhook Sending/Learning

I want to learn something so I came here: how would I make it send a textbox.text value?

local script:

local Host = script.Parent.Parent.Parent.Host.TextBox
local Time = script.Parent.Parent.Parent.Time.TextBox


script.Parent.MouseButton1Click:Connect(function(player)
	game.ReplicatedStorage.TrainingPanelGui.Announce:FireServer(Host,Time)
end)

script.Parent.TouchTap:Connect(function(player)
	game.ReplicatedStorage.TrainingPanelGui.Announce:FireServer(Host,Time)
end)

server script:

local HttpService = game:GetService("HttpService")
local webhook = ""

game.ReplicatedStorage.TrainingPanelGui.Announce.OnServerEvent:Connect(function(Host,Time)
	local data = {
		["name"] = game.Name .. " Training Announcements",
		["title"] = "Training Announcement",
		["type"] = "rich",
		["color"] = Color3.fromRGB(158, 23, 255),
		["content"] = Host.PlayerGui.TrainingPanel.Frame.Announce.Host.TextBox.Text .. "e",
		["fields"] = {
			{
				["name"] = "Host",
				["value"] = Host,
				["inline"] = false
			},
			{
				["name"] = "Time",
				["value"] = Time,
				["inline"] = false
			}
		}
	}
	HttpService:PostAsync(webhook, HttpService:JSONEncode(data))
end)
1 Like

for this in the server script i would set the text in the server script.

You should send the TextBox.Text, since client-sided manipulation does not replicate to server automatically.

Will be looking like this:

LocalScript

local Host = script.Parent.Parent.Parent.Host.TextBox
local Time = script.Parent.Parent.Parent.Time.TextBox


script.Parent.MouseButton1Click:Connect(function(player)
	game.ReplicatedStorage.TrainingPanelGui.Announce:FireServer(Host,Time, Host.TextBox.Text)
end)

script.Parent.TouchTap:Connect(function(player)
	game.ReplicatedStorage.TrainingPanelGui.Announce:FireServer(Host,Time, Host.TextBox.Text)
end)

ServerScript

local HttpService = game:GetService("HttpService")
local webhook = "https://discord.com/api/webhooks/--"

game.ReplicatedStorage.TrainingPanelGui.Announce.OnServerEvent:Connect(function(Player, Host,Time, HostText)
	local data = {
		["name"] = game.Name .. " Training Announcements",
		["title"] = "Training Announcement",
		["type"] = "rich",
		["color"] = Color3.fromRGB(158, 23, 255),
		["content"] = HostText .. "e",
		["fields"] = {
			{
				["name"] = "Host",
				["value"] = Host,
				["inline"] = false
			},
			{
				["name"] = "Time",
				["value"] = Time,
				["inline"] = false
			}
		}
	}
	HttpService:PostAsync(webhook, HttpService:JSONEncode(data))
end)
1 Like

Seems I’m getting error “HTTP 404 (Bad Request)”

Is it only happening with modified one? It’s weird if it is

I remade it to this:

local HttpService = game:GetService("HttpService")
local webhook = ""

game.ReplicatedStorage.TrainingPanelGui.Announce.OnServerEvent:Connect(function(HostText, TimeText)
	local data = {
		content = "**Training** \nYour host," .. HostText .. " will be hosting a training at our training game at " .. TimeText .."!";
		username = game.Name .. " Training Announcement";
	}

	HttpService:PostAsync(webhook, HttpService:JSONEncode(data))
end)

Yet now I’m getting error “attempt to concatenate Instance with string”
Can you also remove the webhook please? :slight_smile:

Been taken care of!

PLEASE REMOVE YOUR WEBHOOK TOKEN OH NO.

People are able to mass spam the hook, and you should never give it out in the open, delete & lmk so I can delete this quote.

Oops! Didn’t realize I didn’t delete it that time. It’s deleted.

1 Like

HostText.Text is most likely whats missing here + TimeText.Text, also,

Make sure this is ["content"], not sure if it effects JSON encoding, but yeah.

The error is “Text is not a valid member of Player “Players.ItsBenDev””.

First parem of a remote event is the player, so do
:Connect(function(Player, HostText, TimeText)

Then it comes up with error "Announce:6: attempt to concatenate nil with string "

brave_v59BQMm5rB

You’re passing in 3 arguments from the client, only one of them being a .Text thing

I since updated it to this:

local HostText = script.Parent.Parent.Parent.Host.TextBox.Text
local TimeText = script.Parent.Parent.Parent.Time.TextBox.Text


script.Parent.MouseButton1Click:Connect(function(player)
	game.ReplicatedStorage.TrainingPanelGui.Announce:FireServer(HostText, TimeText)
end)

script.Parent.TouchTap:Connect(function(player)
	game.ReplicatedStorage.TrainingPanelGui.Announce:FireServer(HostText, TimeText)
end)

Then TimeText.Text or HostText.Text is nil, try printing our their values/printing their names to make sure they exist.

After printing it it prints: " "

And HostText/TimeText.Text prints “nil”

Is empty, I really don’t know much about this system, but make sure these paths are correct & make sure you are filling the textfields.