Web Hook Erroring

Trying to make a webhook for my anticheat:

local webhook = "--Discord link here"
local http = game:GetService("HttpService")
local WebhookFunction = game.ReplicatedStorage.ACBAN

function WebhookFunction.OnServerEvent(player, ID, Reason, System)
    local data = {
					embeds = {{
                        title = "Anti-Exploit";
                        description = "Player Banned!";
                        color = 8376188;
                        fields = {
                                    {
                                        name = "Player Name";
                                        value = player.Name
                                    };
                                    {
                                        name = "Player User ID";
				                     	value = player.UserId
                                    };
                                    {
                                        name = "Reason";
                                        value = "Exploiting"
                                    };
									 {
                                        name = "Anti-Cheat And Webhook made by Mystery_Devx & NotTheAverageUser1";
                                        value = System
                                    }
                                }
                            }}
                        }
                        local transmit = http:JSONEncode(data)
                        http:PostAsync(webhook,transmit)
end

and I’m getting this error:

I’m assuming that the script couldn’t know if it was an event of the remote event. Connect a function using Connect, and then the parameters that came from the remote event will automatically be perceived.

WebhookFunction.OnServerEvent:Connect(function(player, ID, Reason, System)

Thank you for the response but that didn’t work either.


image
image

It’s just full of error’s now.

I modified it a little and I come with this error now:

game.Players.PlayerAdded:Connect(function(player)

local webhook = "--webhook link"
local http = game:GetService("HttpService")
local WebhookFunction = game.ReplicatedStorage.BanEvent


local player = game.Players.PlayerAdded:Connect(function(player)
local ID = player.UserId

function WebhookFunction()

    local data = {
					embeds = {{
                        title = "Anti-Exploit";
                        description = "Player Banned!";
                        color = 8376188;
                        fields = {
                                    {
                                        name = "Player Name";
                                        value = player.Name
                                    };
                                    {
                                        name = "Player User ID";
				                     	value = player.UserId
                                    };
                                    {
                                        name = "Reason";
                                        value = "Exploiting"
                                        
                                    }
                                }
                            }}
                        }
                        local transmit = http:JSONEncode(data)
	http:PostAsync(webhook,transmit)
	
end

WebhookFunction()

		game.ReplicatedStorage.BanEvent.OnServerEvent:Connect(function(WebhookFunction)
		end
	end)

image

WebhookFunction()

		game.ReplicatedStorage.BanEvent.OnServerEvent:Connect(WebhookFunction)

edit: can you please indent the code properly and the remoteevent BanEvent is incorrectly used, there’s no player argument included

1 Like

Yes, Thats what I’m confused on. Can you show me how to do it. I’m not really good with webhooks and using external applications.

lets go back to the original script you made, firstly thats not how to connect remoteevents on the server, i thought this was a function inside a modulescript ^

local webhook = "--Discord link here"
local http = game:GetService("HttpService")
local WebhookFunction = game.ReplicatedStorage.ACBAN

WebhookFunction.OnServerEvent:Connect(function(player, ID, Reason, System) -- see where this is going? Connecting events will always be in this format, i can't really explain it properly but the gist is thsi is how to connect remoteevents to a function 
    local data = {
					embeds = {{
                        title = "Anti-Exploit";
                        description = "Player Banned!";
                        color = 8376188;
                        fields = {
                                    {
                                        name = "Player Name";
                                        value = player.Name
                                    };
                                    {
                                        name = "Player User ID";
				                     	value = player.UserId
                                    };
                                    {
                                        name = "Reason";
                                        value = "Exploiting"
                                    };
									 {
                                        name = "Anti-Cheat And Webhook made by Mystery_Devx & NotTheAverageUser1";
                                        value = System
                                    }
                                }
                            }}
                        }
                        local transmit = http:JSONEncode(data)
                        http:PostAsync(webhook,transmit)
end)
2 Likes

This may help.