I need help with my roblox to discord

You can write your topic however you want, but you need to answer these questions:
I want to be able to send a message from Roblox to my webhook. For some reason, it only works in studio not in-game. I have tried to find solutions, but couldn’t find any.

Here are my scripts
This one is the regular one.

local Webhook = require(script.Webhook)
local WebookSender = game:GetService("ReplicatedStorage").WebhookSender

WebookSender.OnServerEvent:Connect(function(Player: Player, Message: Message, WEBHOOK_URL: URL, COLOR: HEX)
	Webhook:SendMessage(Player, Message, WEBHOOK_URL, COLOR)
end)

Here is the module

local HttpService = game:GetService("HttpService")

local Webhook = {}

function Webhook:SendMessage(Player: Player, Message: StringValue, WEBHOOK_URL: URL, COLOR: HEX) : "Sends a message"
	local Data = {
		["embeds"] = {{
			["author"] = {
				["name"] = Player.Name.."["..Player.UserId.."] ["..Player.AccountAge.."]"
			},
			["color"] = tonumber("0x"..COLOR),
			["fields"] = {
				{
					["name"] = "Message: ",
					["value"] = Message,
					["inline"] = false
				},
				{
					["name"] = "Date: ",
					["value"] = os.date("%x").." "..os.date("%X"),
					["inline"] = false
				}
			}
		}}
	}
	Data = HttpService:JSONEncode(Data)
	local Success, Error = pcall(function()
		HttpService:PostAsync(WEBHOOK_URL, Data)
	end)
	if not Success then
		warn(Error)
	end
end

return Webhook

It works perfectly fine in studio, but doesn’t show up in-game.
It is also giving me an error called HTTP 403 (Forbidden)
image
If anyone knows how to fix that.

1 Like

Can’t remember which way around it is, but ROBLOX and Discord are prohibited from interacting with each other. You’ll have to proxy your requests.

It works in studio though, but it doesn’t work in game.

The difference being that, in studio, you’re emulating a ROBLOX server. Your local machine acts as both the client and the server, so you’re sending a request to Discord from your machine. When you try the same thing in-game, you’re sending a request from a ROBLOX server, which Discord blocks (probably due to the user-agent sent with the request - but I’m not certain about this!)

Try this using this! https://hooks.hyra.io/
Hyra (the URL I just sent) acts as a proxy, allowing you to send requests without it showing up as Error 403.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.