Help with a webhook script

Server Script

game.ReplicatedStorage.ArrestCuffEventsWow.BookingPlayer.OnServerEvent:Connect(function(PlayerYes, PlaTarg, CrimeComm, ArrestDesc)
	local HttpService = game:GetService ("HttpService")
	local webhook = "https://discord.com/api/webhooks//###"
	
	local data = {
		["content"] = "",
		["embeds"] = {{
			["title"] = "Arrest Log",
			["color"] = 3450671,
			["fields"] = {
				{
					["name"] = "Officer Name",
					["value"] = PlayerYes
				},
				{
					["name"] = "Suspect Name",
					["value"] = PlaTarg
				},
				{
					["name"] = "Crime Committed",
					["value"] = CrimeComm
				},
				{
					["name"] = "Arrest Description",
					["value"] = ArrestDesc
				}
			}}
		}
	}

	local jsonData = HttpService:JSONEncode(data)
	HttpService:PostAsync(webhook, jsonData)
end)

Local Script

local PlayerYes = game.Players.LocalPlayer
local HS = game:GetService("HttpService")
local PlaTarg = PlayerYes.Target.Value
local CrimeComm = script.Parent.Parent.CrimeCommitted.Text
local ArrestDesc = script.Parent.Parent.ArrestDescription.Text

function OnClick(Clicked)
	print(PlayerYes.Target.Value)
	if PlayerYes.Target.Value == game.Players:FindFirstChild(PlayerYes.Target.Value).Name then
		print(PlayerYes.Target.Value)
		game.ReplicatedStorage.ArrestCuffEventsWow.BookingPlayer:FireServer(PlayerYes, PlaTarg, CrimeComm, ArrestDesc)
	end
end

script.Parent.MouseButton1Click:Connect(OnClick)

The problem is, this error lua 15:21:41.380 HTTP 400 (Bad Request) - Server - BookingServerWowOk:32

So basically, it’s rejecting the crime committed and the arrest description for some reason roblox doesnt want to send it. Please someone help!!

The value only accepts strings, not instances. In the “Officer Name”, you’re referencing the Player Instance, therefore you need to change its value to, PlayerYes.Name.

1 Like

Yes, I know, but thats not the problem, I fixed that. The problem is the arrest desc and crim committed

You don’t need to pass the localplayer to the server, the server already knows who fired the remote

game.ReplicatedStorage.ArrestCuffEventsWow.BookingPlayer:FireServer(PlaTarg, CrimeComm, ArrestDesc)

The color is wrong, it should be I think like 0x3450671

Oh and you shouldn’t pass the player who is firing the event as an argument, that’s already an argument on the server so your local script should look like:

function OnClick(Clicked)
	print(PlayerYes.Target.Value)
	if PlayerYes.Target.Value == game.Players:FindFirstChild(PlayerYes.Target.Value).Name then
		print(PlayerYes.Target.Value)
		game.ReplicatedStorage.ArrestCuffEventsWow.BookingPlayer:FireServer( PlaTarg, CrimeComm, ArrestDesc)
	end
end

This should work, so replace the function with this new one, here’s also moz docs for HTTP request error 400

thank you, it works now
I also went on other platforms to fix.