A Command Error

local GroupId = 5774015
local httpService = game:GetService("HttpService")
local webhookURL = "the discord webhook url"
local minimumRankToUseCommmand = 3
local function ContactER(DiscordMessage)
	local Data = {
		["content"] = DiscordMessage
	}
	Data = httpService:JSONEncode(Data)
	httpService:PostAsync(webhookURL,Data)
end

game.Players.PlayerAdded:Connect(function(player)
	if player:GetRankInGroup(GroupId) < minimumRankToUseCommmand then
		script:Destroy()
	end
	player.Chatted:Connect(function(Message)
		local SplitMessage = Message:Split(" ")
		if SplitMessage[1] == ":exploiter" then
			local NameOfPotentialExploiter = SplitMessage[2]
			local PotentialExploiter = game.Players:FindFirstChild(NameOfPotentialExploiter)
			ContactER("@765289353215606834, "..NameOfPotentialExploiter.." has been reported for exploiting.")
		end
	end)
end)

This isnt sending the message to the discord.

Please remove the webhook url from your code snippet! Bad actors can just grab it right now and abuse it.

As for the problem I’ll get back to you on it shortly on that, but do remove it asap.

My bad, I just changed the line.

All good haha.

Anyways, the issue appears to be that you’re using :Split() wrong. It should be :split().

As a side note, you shouldn’t be destroying the script if a player joins and they aren’t the correct rank. I fixed up the code for you. Instead, just don’t hook the Chatted event.

local GroupId = 5774015
local httpService = game:GetService("HttpService")
local webhookURL = ""
local minimumRankToUseCommmand = 3
local function ContactER(DiscordMessage)
	local Data = {
		["content"] = DiscordMessage
	}
	Data = httpService:JSONEncode(Data)
	httpService:PostAsync(webhookURL,Data)
end

game.Players.PlayerAdded:Connect(function(player)
	if player:GetRankInGroup(GroupId) >= minimumRankToUseCommmand then
		player.Chatted:Connect(function(Message)
			local SplitMessage = Message:split(" ")
			if SplitMessage[1] == ":exploiter" then
				local NameOfPotentialExploiter = SplitMessage[2]
				local PotentialExploiter = game.Players:FindFirstChild(NameOfPotentialExploiter)
				ContactER("@765289353215606834, "..NameOfPotentialExploiter.." has been reported for exploiting.")
			end
		end)
	end
end)

Sorry for late response, I was at my golf practice. Thank you! This works, but one problem, it doesnt ping the role, it just says @the numbers. Is there a way to get it to ping the role?

Nevermind, got it to work!
Thank you!