You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
i want it to send the report to the webhook on the discord server -
What is the issue? Include screenshots / videos if possible!
I’m having an issue getting my report player command working that well send a webhook with the reason the player was reported for but I’m getting an error saying Number of requests exceeded the limit Hers my script I take out the webhook URL because that’s private
local HttpService = game:GetService("HttpService")
local Players = game:GetService("Players")
local webhookUrl = ""
local reportCooldown = 60
local cooldowns = {}
local function sendReportToDiscord(reporter, reportedUsername, reason)
local data = {
["content"] = "",
["embeds"] = {{
["title"] = "Player Report",
["description"] = "**Reporter:** " .. reporter.Name .. "\n**Reported Player:** " .. reportedUsername .. "\n**Reason:** " .. reason,
["color"] = 16711680,
}}
}
local headers = {
["Content-Type"] = "application/json"
}
local request = {
Url = webhookUrl,
Method = "POST",
Headers = headers,
Body = HttpService:JSONEncode(data)
}
HttpService:RequestAsync(request)
end
Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
local args = message:split(" ")
if args[1] == "!report" then
local currentTime = tick()
if cooldowns[player.UserId] and currentTime - cooldowns[player.UserId] < reportCooldown then
player:SendNotification({
Title = "Cooldown Active",
Text = "Please wait before sending another report.",
Duration = 5
})
return
end
if #args >= 3 then
local reportedUsername = args[2]
local reason = table.concat(args, " ", 3)
sendReportToDiscord(player, reportedUsername, reason)
cooldowns[player.UserId] = tick()
player:SendNotification({
Title = "Report Sent",
Text = "Your report has been sent to the staff.",
Duration = 5
})
else
player:SendNotification({
Title = "Invalid Command",
Text = "Usage: !report <username> <reason>",
Duration = 5
})
end
end
end)
end)