I have a game where I am making an admin panel that anyone can use, however the more destructive commands like kill all and BTools have an anticheat system around them. for players who want to use these, they have to be whitelisted, the problem is that anticheat system takes a little bit to go through and makes the game look laggy.
the way my GUI works is the following:
first, a local script sends this:
Auth:FireServer("stop reading my scripts", "Cheese")
then, my anticheat script does this:
math.randomseed(tick())
local Code
local Auth = game.ReplicatedStorage.AuthRequest
local BEvent = game.ReplicatedStorage.AuthEvent
local Package = game.ReplicatedStorage.SendPackage
local Count = 0
Auth.OnServerEvent:Connect(function(Plr, Auth1, Auth2)
local function CheckPlr()
for i, v in ipairs(game.Players:GetChildren()) do
if v.Name == Plr.Name then
return true
elseif Count == #game.Players:GetChildren() then
return false
end
Count = Count + 1
end
end
if CheckPlr() == true and Auth1 == "stop reading my scripts" and Auth2 == "Cheese" then
Code = math.random(1, 1000000)
print(Code)
end
BEvent:Fire(Code)
if Code ~= nil then
Package:FireClient(Plr, Code)
end
end)
then, my local script receives the code and does this:
Package.OnClientEvent:Connect(function(Pass)
AuthCode = Pass
end)
then, my local script calls a separate remote to preform the command. the local script passes through the name of the command and the code it got from the anticheat, and then the script that preforms the commands checks to see if it has the same code that was passed through from the remote, if it does it does the command, if not it does nothing. (yes, I know this is not a whitelist system, I am not done with that part.)
my problem is I have to add a wait(0.1)
before I send the command and the code over to the script that preforms the commands, otherwise AuthCode equals nil
and nothing works. here is my question: how can I remove the wait? I have gotten multiple people saying it feel a little unresponsive, is my anticheat script inefficient? do I need the wait? is there some better way to do this anticheat that I did not think of?
all help is welcome, thanks for taking the time to read this!