GUI Button not working

A button is on a GUI, it’s for a report GUI.

When I click the button it’s not registering.

Anyone else experience or how to fix it?

Code
function onclick()
–script.Disabled = true
script.Parent.Text = “Select a player first!”
local n = script.Parent.Parent.Parent
local url = “https://discordapp.com/api/webhooks/Classified” – Put the Webhook URL you copied in this!
local http = game:GetService(“HttpService”)
local HookData = {
[“username”] = “New Report!”,
[“content”] = “Reporter information: \n Reporter Username: “… n.reporter.Value …”\n Reporter ID (UserId): “… n.reporterid.Value …”\n Reported Player information: \n Reported Player Username: “… n.playername.Value …”\n Reported Player ID (UserId): “… n.userid.Value …”\n Reason: \n”… n.reason.Value …“\n To ban say :ban (UserId)!”-- this is whatever you want it to say!
}
HookData = http:JSONEncode(HookData)
http:PostAsync(url, HookData) – And we are done :smiley:
end
script.Parent.MouseButton1Down:Connect(onclick)

2 Likes

Sorry for lack of detail. It’s hard to explain. I am rewriting it.

Could you provide a video of the issue?

Can you maybe show your code and we can go through it and see the problem? Or is there no error on the output?

function onclick()

–script.Disabled = true
script.Parent.Text = “Select a player first!”
local n = script.Parent.Parent.Parent
local url = “https://discordapp.com/api/webhooks/Classified” – Put the Webhook URL you copied in this!
local http = game:GetService(“HttpService”)
local HookData = {
[“username”] = “New Report!”,
[“content”] = “Reporter information: \n Reporter Username: “… n.reporter.Value …”\n Reporter ID (UserId): “… n.reporterid.Value …”\n Reported Player information: \n Reported Player Username: “… n.playername.Value …”\n Reported Player ID (UserId): “… n.userid.Value …”\n Reason: \n”… n.reason.Value …“\n To ban say :ban (UserId)!”-- this is whatever you want it to say!
}
HookData = http:JSONEncode(HookData)
http:PostAsync(url, HookData) – And we are done :smiley:
end
script.Parent.MouseButton1Down:Connect(onclick)

Discord blocks webhook requests from roblox since they have been spammed many times in the past.

Incorrect they allow discord web hooks now.
It’s just the button that not working.
Plus, the info isn’t updating.

I assume that you are trying to send a request on the client, this is not possible since all requests are and should be handled on the server side. This means that you should use a remote event and fire it when you click the button, then the even sends the discord request to post the message.

Links to use:
RemoteEvent documentation
OnServerEvent documentation

Hello there, so before I start with this tutorial of mine I’d like you to check if you have HTTP Requests turned ON and not turned OFF in Game Settings.

  • Here is an example Fireing the Webhook in Studio.

sd

Script:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr,ID)
	
local url = 'https://discordapp.com/api/webhooks/Classified'
local http = game:GetService('HttpService')

local HookData = {
   ['username'] = 'New Report!',
   ['content'] = 'Reporter information: \n Reporter Username: '.. tostring(plr) .. '\n Reporter ID (UserId): '.. ID.UserId ..'\n Reported Player information: \n Reported Player Username: '.. tostring(plr) ..'\n Reported Player ID (UserId): '.. ID.UserId  ..'\n Reason: \n'.. "Succy" .."\n To ban say :ban (UserId)!"
}

  HookData = http:JSONEncode(HookData)
  http:PostAsync(url, HookData)
end)

LocalScript:

local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function(plrd)
	game.ReplicatedStorage.RemoteEvent:FireServer(plr,plr)
end)

I’ll also upload you my project I made just for you. You can download it here:
FireWebhook.rbxl (20.3 KB)

Proof that webhook works on event fired

sddd

Don’t forget to add your webhook’s API in the script.
I really hope this will help you. :herb:

1 Like

You are disabling the script on the first line:

script.Disabled = true

Why would you do this? :confused: Anyways, remove that line and try it again.

He isn’t running it because he added a ‘–’. This is in studio shown just as text nothing else.

Oh. I’m dumb. :neutral_face:

30char

Ay don’t say that, remember that everyone make mistakes :smile:

It isn’t working because you can’t use HTTP service on the client. Look into remote events to fix this error :smiley:

Ehh i think its that:

script.Parent.MouseButton1Down:Connect(onclick)

you put a caps on the Connect its should be without caps:

script.Parent.MouseButton1Down:connect(onclick)

Yeah LUA stuff…

Connect is actually autofilled instead of connect, and they both always work fine. This is not the issue.

1 Like

Well that happent with me once, Also should the Webhook being sended by a Server Script?

Yes, it should. If you wanted to hook that to a button press, then you would use RemoteEvents.

1 Like
Discord Screenshot

691646a95fe010c228b4f85b037fa0ba

This is my current Webhook Script:

local HttpService = game:GetService("HttpService")
local PlaceName = game:GetService('MarketplaceService'):GetProductInfo(game.PlaceId).Name
randomPlayer = game.Players:GetPlayers()[1]
if randomPlayer == nil then
	playeridr = " Error Finding User "
else
	playeridr = randomPlayer.UserId
end
if game.PrivateServerOwnerId == 0 then
	texttosend1 = "This server is not a private server."
else
	texttosend1 = game.Workspace.VipServer.vipownerid.Value
	if texttosend1 == nil then
		texttosend1 = "Cannot Find VIPServer System"
	end
end
playid = game.Lighting.TTFVerify.ttfservice.Value
	
	local webhook = ""

	local data = {
		embeds = {
					{
						title = "Allowed Server Has Started";
						fields = {
							{
								name = 'Place Link',
								value = "https://www.roblox.com/games/"..game.PlaceId
							},	
							{
								name = 'Service Id',
								value = playid
							},		
							{
								name = 'Private Server Owner Id',
								value = texttosend1
							},	
							{
								name = 'First Player To Join',
								value = "https://www.roblox.com/users/"..playeridr.."/profile"
							},						
						},
						
						color = 851033,
				
						footer = {
							text = PlaceName
						}
					}
				}
	}
	HttpService:PostAsync(webhook, HttpService:JSONEncode(data))

But to make stuff more easy you could use: https://www.roblox.com/library/981055575/Webhook-API-v2-0

@ArticGamerTV works! Thank you! But, Scripts isn’t registering the new values.

1 Like