Why isn't this working?

When I join the game it shows an error (Bad Request 404). Does anyone know what I’m doing wrong here? This script sends an embed via a webhook.

local Webhook = "N/A"
local HttpService = game:GetService("HttpService")

game.Players.PlayerAdded:Connect(function(plr)
	local data = {
		['embeds'] = {{
			["author"] = {
				["name"] = plr.Name,
				["icon_url"] = game:GetService("Players"):GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150),
			},
			['description'] = plr.Name.." heeft ***"..game.Name.."*** gejoined",
			['color'] = 082888,
			['url'] = "https://www.roblox.com/users/"..plr.UserId.. "/profile",

			['fields'] = {
				{
					['name'] = "AccountAge: ",
					['value'] = "Dit account is **"..plr.AccountAge.."** dagen oud",
					['inline'] = true
				},
				{
					['name'] = "Displayname: ",
					['value'] = plr.DisplayName, 
					['inline'] = true
				},
				{
					['name'] = "UserID: ",
					['value'] = plr.UserId,
					['inline'] = true
				}
			}
		}}
	}
	HttpService:PostAsync(Webhook, HttpService:JSONEncode(data))
end)
2 Likes

Yo bro change the post quick you just sent your webhook.

1 Like

oh i havent seen that i send it tho, thanks

1 Like

You might as well update the webhook bot later for safety reasons.

2 Likes
local Webhook = "https://discord.com/api/webhooks/1195704311905275966/yL9SWZj1J-YxA1_hUmtP-lxWWIqDOkEZJvFQVSHb57xyXG6hsbzlWvZ-kx6UENnxgO1m"
local HttpService = game:GetService("HttpService")

-- Create a table to store user data
local userData = {}

-- Function to get user data
local function getUserData(userId)
    return userData[userId]
end

-- Function to handle player joining
local function onPlayerJoined(plr)
    -- Store the user's information
    userData[plr.UserId] = {
        Name = plr.Name,
        DisplayName = plr.DisplayName,
        AccountAge = plr.AccountAge,
        UserId = plr.UserId
    }
    
    -- Create the embed
    local data = {
        ['embeds'] = {{
            ["author"] = {
                ["name"] = plr.Name,
                ["icon_url"] = game:GetService("Players"):GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150),
            },
            ['description'] = plr.Name.." heeft ***"..game.Name.."*** gejoined",
            ['color'] = 082888,
            ['url'] = "https://www.roblox.com/users/"..plr.UserId.. "/profile",

            ['fields'] = {
                {
                    ['name'] = "AccountAge: ",
                    ['value'] = "Dit account is **"..plr.AccountAge.."** dagen oud",
                    ['inline'] = true
                },
                {
                    ['name'] = "Displayname: ",
                    ['value'] = plr.DisplayName, 
                    ['inline'] = true
                },
                {
                    ['name'] = "UserID: ",
                    ['value'] = plr.UserId,
                    ['inline'] = true
                }
            }
        }}
    }
    
    -- Send the embed
    HttpService:PostAsync(Webhook, HttpService:JSONEncode(data))
end

-- Connect the function to the player added event
game.Players.PlayerAdded:Connect(onPlayerJoined)

Update your webhook, please!

1 Like

I have already created a new webhook, but this script also shows Error 400 (Bad Request)

1 Like

Ahhh, those errors… Let’s wait for an advanced programmer to come and help you. We aren’t enough for that.

1 Like

Your webhook, is it one from discrod itself? Because I think you can’t send it directly to discord itself.

Try looking at this:

and this:

You can also try this out.
local finaldata = HttpService:JSONEncode(data)
HttpService:PostAsync(Webhook, finaldata)

roblox disabled discord api, try to search for discord api plugins on discord

You cant help you sorry about use