Webhook not working

Mk, you’ve got the color wrong. It needs to be formatted in a certain way. Something like 0x before it. Lemme check out what I have for my script. Please send over the error.

There’s no errors, that the issue tho. Else I would have fixed it…

So you mean the webhook isn’t calling at all.

You need something formatted like this:

["color"] = tonumber(0xed0404),

To get this: Use
0x and then add your hex color.
You can get it from here: hex color - Google Search
Then you add the hex color and make it 0xed0404

But the other issue likely means that the event isn’t working/you might have the wrong object.

The way you have your code is confusing, if this is in a textbutton there’s 0 need for a playeradded event, and I’m pretty sure webhooks don’t work locally even after you do that change, so you need a remoteevent to fire the webhook after clicking, and you’d also need to format the color correctly from what I have saw otehrs do with their webhook since you’d need to pass in a hex code as the person above me mentioned

Which mean my code would become? Sorry I’m really confused lol.

You do not need the playeradded event and you need to put all the webhook related code in a RemoteEvent’s OnServerEvent which you then FireServer

What @EmbatTheHybrid is saying is that your code is not well written. You can just fix it with:

local url = "" -- webhook
local http = game:GetService("HttpService")

script.Parent.Parent.Call.MouseButton1Click:Connect(function(plr)
		local data = {
			["content"] = '',
			["embeds"] = {{
				["title"] = "Mod Call",
				["description"] = plr.Name.." is in need of assistance!",
				["color"] = tonumber(0x1d8dde),
			}}
		}
		data = http:JSONEncode(data)
		http:PostAsync(url, data)
	end)

The thing is, is that clickdetectors always give the player instance. So you don’t need a player added event.

That will still not work as the webhook needs to be posted from the server, and this is not a clickdetect, this is a TextButton/ImageButton and MouseButton1Click does not return anything, and thus will give an attempt to index nil with Name error

1 Like

So now it’s should be fixed, right?

Confusion 100… What would be my final script??

We can’t give you final scripts/write them for you, we can only help you figure out your issues and it’s up to you to make the final pieces of scripts. If you don’t know how RemoteEvents work, research on them.

But to give a bit of a boost, you’d have code similar to this

PseudoCode

TextButton.MouseButton1Click:Connect(function()
    RemoteEvent:FireServer()
end)
--Server script
RemoteEvent.OnServerEvent:Connect(function(plr)
    --Your webhook code
end)

Okay, so I misunderstood, and it seems to be a GUI, Thanks Embat. You need to use a remote event to contact the server to tell them about the webhook and to fire it.

LocalScript

script.Parent.Parent.Call.MouseButton1Click:Connect(function()
   game.ReplicatedStorage.YourRemoteEvent:FireServer()
end)

ServerScript (ServerScriptService is best)

game.ReplicatedStorage.YourRemoteEvent.OnServerEvent:Connect(function(plr)
   local data = {
			["content"] = '',
			["embeds"] = {{
				["title"] = "Mod Call",
				["description"] = plr.Name.." is in need of assistance!",
				["color"] = tonumber(0x1d8dde),
			}}
		}
		data = http:JSONEncode(data)
		http:PostAsync(url, data)
	end)
end)

You just need to place your remote event in. If you’re confused on how it works, please check out Bindable Events and Functions | Roblox Creator Documentation and Client-Server Model | Roblox Creator Documentation

TextButton.MouseButton1Click:Connect(function()
RemoteEvent:FireServer()
end)

This code stays in the main webhook script?

No…It’s the code inside of where you originally have your entire code in, the RemoteEvent code is in a regular script that preferably is in ServerScriptService

Check out what I said about the type of script and location.

1 Like

Alright, thanks for the help let me see if that works!

game:GetService(“StarterGui”).ModCall.ModCallButton:Connect(function()

game.ReplicatedStorage.ModCall:FireServer()

end)

Would that work?

^^ Would that work or no? -----

No, you’re getting the gui object from StarterGui, just put the FireServer code as a loaclscript inside of the button and change the references accordingly

What’s the issue? I tested that table and it sends just fine.

image

It must be a problem outside of the webhook call itself. Try setting up some prints to see what is and isn’t being run.

Also, make sure the webhook call occurs on the server. It looks like you’re setting this up in the same script as GUI object code, which are usually modified locally.