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

Why is this not working? (Discord Webhook Related)

Note: I'm making a GUI Voting System. So basically, when the player clicks the TextButton, it will send a message with the player's username. But it dosen't work. Please check my script.

    script.Parent.MouseButton1Click:connect(function(plr)

    local http = game:GetService("HttpService")

local Data = {

["content"] = plr.Name, "Voted for PRR"

}

  

Data = http:JSONEncode(Data)

  

http:PostAsync("https://discordapp.com/api/webhooks/566241492218282018/ITWAhltgl-c_fy7whA8b2uhDYthnjWPV4z_60K5pVX7MTrIvPTsqrIHq6lh67ONn0sCH", Data)

end)

2 comments

0

You should delete the webhook link since it is private and can be abused by others.

0

^

1 answer

Hello. You should NOT use Discord for logging. But here I fixed your code.

-- LocalScript
local Player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	local Data = {
		["content"] = Player.Name.. " voted for PRR!"
	}
	game.ReplicatedStorage.SendPost:FireServer(Data)
end)

///

-- ServerScript
local HttpService = game:GetService("HttpService")

local URL = "https://discord.osyr.is/your webhook here"

  

game.ReplicatedStorage.SendPost.OnServerEvent:Connect(function(player, data)

HttpService:PostAsync(URL,HttpService:JSONEncode(data))

end)

So, the Client cannot send HttpRequests. You will use a Remote Event to send the data from the client to the server. The server will send the data. In the first code, the data will be sent to the server through the remote event when the player clicks the TextButton / ImageButton.

In the second script, as you can see, I used https://discord.osyr.is instead of https://discordapp.com since Discord does not allow that. So you have to use a webserver. Some information about osyr: Click Me After the data is received from the Remote Event, the Server will send it to Discord. And here is the result: Result

1 comment

0

yah pretty much, i like that you spent your time making a bot too xd

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