So I'm trying to create an anti-cheat script I saw in a game. It would detect if there is a new undetected GUI for a player (e.g a remotespy GUI) so it will ban it. However, whenever I write game.CoreGui, it will just say The current identity (2) cannot Class security check (lacking permission 1). The localscript is in StarterCharacterScripts. I got 2 actually, one has this:

local plr = game.Players.LocalPlayer
game.DescendantAdded:Connect(function(d) 
	if (d.Parent==game.CoreGui) then
		if (d.Name == "SpyScroller") then
			local http = game:GetService("HttpService")
	local Data = {
		["content"] = plr.Name .. " used a cheat. Cheat: Not game-source local GUI! Probably using remote spy. Banned for 1 week!"
	}

	Data = http:JSONEncode(Data)
	http:PostAsync("mydiscordwebhooklink", Data) --Put the link you saved between the two quotes.
	plr:Kick("You have been banned for using cheats! Duration: 1 week! Appeal in our discord server, #banappeals")
		end
	end
end)

and one has this:

local safeguinames = {"admingui"}
local normalamount = 4 --Don't edit this.
local plr = game.Players.LocalPlayer
while wait() do
	if (#plr.PlayerGui:GetChildren() >= #safeguinames) then
		--check if it's admingui
		if (#plr.PlayerGui:GetChildren() == 5 and plr.PlayerGui:FindFirstChild("admingui")==false) then
			--ban.
			local http = game:GetService("HttpService")
			local Data = {
				["content"] = plr.Name .. " used a cheat. Cheat: Not game-source local GUI! Probably using remote spy. Banned for 1 week!"
			}

			Data = http:JSONEncode(Data)

			http:PostAsync("discordhook", Data) --Put the link you saved between the two quotes.
			plr:Kick("You have been banned for using cheats! Duration: 1 week! Appeal in our discord server, #banappeals")
		end
		
		if (#game.CoreGui:GetChildren()==8) then -- I think this part is not needed if I have that first script, but it still gives the same error
			local http = game:GetService("HttpService")
			local Data = {
				["content"] = plr.Name .. " used a cheat. Cheat: Not game-source local GUI! Probably using remote spy. Banned for 1 week!"
			}

			Data = http:JSONEncode(Data)

			http:PostAsync("stillmydiscordhook", Data) --Put the link you saved between the two quotes.
			plr:Kick("You have been banned for using cheats! Duration: 1 week! Appeal in our discord server, #banappeals")
		end
	end
end
--And I know it won't ban, this is just testing..

EDIT: Don't care about the dumb script I have many things to do with it but I want to solve this problem first. So what should I do?

5 comments

0

Don't rely on local anti exploits. Secure the server. Also, for the question, you don't

0

So then what am I supposed to do? I saw this on Military Simulator. I don't know how they do it if no one else can..?

0

Secure your remote events

0

If they are able to do something from the client, then thats an issue. Make sure you're stopping anything bad from happening by having checks on the server

0

I want to secure my remote events so I asked a question. Basically this is the same project but I gave up on GUIs cuz I'm just not able to do this.. But as I wrote that some people are able to detect this, I know that there is a way :(