Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Not able to send variables through PostAsync Discord webhook?

This is my code. I have no idea why it ain't working.

local main = script.Parent.Parent

script.Parent.MouseButton1Down:Connect(function()
	local http = game:GetService("HttpService")
	local rank = main.First.Rank.Text
	local username
	local priority = tostring(main.Priority.Value)
	local number = tostring(main.Second.Num.Text)
	local reason = tostring(main.Second.Rea.Text)
	local Data = {
		username..", "..rank.." has sent a priority "..priority.." back-up request. "..number.." personnel members are requested for the following reason: "..reason;
	}

	Data = http:JSONEncode(Data)
	http:PostAsync("https://discordapp.com/api/webhooks/...", Data)
end)

3 comments

0

is this a local script? You must post requests on the server, not on the client. Use RemoteEvents for communication. Your [Data] also makes no sense, you need to send what discord requires for it's embed, in your case you need to specify [content] inside of the table, not just send a string.

0

Take a look here: https://discord.com/developers/docs/resources/webhook, scroll down to [Execute] method, it shows exactly what discord webhook requires.

0

@imKirda No, it is a serverscript. I still cannot figure out how that works. Would you help me?

1 answer

do something like

local Data = {
	["content"] = "msg content",
	["title"] = "msg title"
}
Data = http:JSONEncode(Data)
http:PostAsync("webhook url", Data)

etc

this should work

13 comments

0

It didn't, the content still won't read my variables.

0

It didn't, the content still won't read my variables.

0

It didn't, the content still won't read my variables.

0

It didn't, the content still won't read my variables.

0

It didn't, the content still won't read my variables.

0

It didn't, the content still won't read my variables.

0

It didn't, the content still won't read my variables.

0

It didn't, the content still won't read my variables.

0

It didn't, the content still won't read my variables.

0

It didn't, the content still won't read my variables.

0

It didn't, the content still won't read my variables.

0

It didn't, the content still won't read my variables.

0

It didn't, the content still won't read my variables.

This discussion is preserved as it was. New answers, comments, and votes are closed.