How to access CoreGui from a local script?
Asked by
5 years ago Edited 5 years ago
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:
01 | local plr = game.Players.LocalPlayer |
02 | game.DescendantAdded:Connect( function (d) |
03 | if (d.Parent = = game.CoreGui) then |
04 | if (d.Name = = "SpyScroller" ) then |
05 | local http = game:GetService( "HttpService" ) |
07 | [ "content" ] = plr.Name .. " used a cheat. Cheat: Not game-source local GUI! Probably using remote spy. Banned for 1 week!" |
10 | Data = http:JSONEncode(Data) |
11 | http:PostAsync( "mydiscordwebhooklink" , Data) |
12 | plr:Kick( "You have been banned for using cheats! Duration: 1 week! Appeal in our discord server, #banappeals" ) |
and one has this:
01 | local safeguinames = { "admingui" } |
03 | local plr = game.Players.LocalPlayer |
05 | if (#plr.PlayerGui:GetChildren() > = #safeguinames) then |
07 | if (#plr.PlayerGui:GetChildren() = = 5 and plr.PlayerGui:FindFirstChild( "admingui" ) = = false ) then |
09 | local http = game:GetService( "HttpService" ) |
11 | [ "content" ] = plr.Name .. " used a cheat. Cheat: Not game-source local GUI! Probably using remote spy. Banned for 1 week!" |
14 | Data = http:JSONEncode(Data) |
16 | http:PostAsync( "discordhook" , Data) |
17 | plr:Kick( "You have been banned for using cheats! Duration: 1 week! Appeal in our discord server, #banappeals" ) |
20 | if (#game.CoreGui:GetChildren() = = 8 ) then |
21 | local http = game:GetService( "HttpService" ) |
23 | [ "content" ] = plr.Name .. " used a cheat. Cheat: Not game-source local GUI! Probably using remote spy. Banned for 1 week!" |
26 | Data = http:JSONEncode(Data) |
28 | http:PostAsync( "stillmydiscordhook" , Data) |
29 | plr:Kick( "You have been banned for using cheats! Duration: 1 week! Appeal in our discord server, #banappeals" ) |
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?