So I am trying to make an anti-cheat. What I am trying to do is to protect my remote events from being deleted. I have tried using this script but it does not work at all because the events do not replicate correctly (runs every frame in pcall)
function CheckObj()
local Comms = game.ReplicatedStorage:FindFirstChild("Comms")
local HammerComms = game.ReplicatedStorage:FindFirstChild("HAMMERCOMMS")
local ChatEvent = game.ReplicatedStorage:FindFirstChild("ChatMessageEvent")
local ShowGui = game.ReplicatedStorage:FindFirstChild("ShowGui")
local updateCash = game.ReplicatedStorage:FindFirstChild("updateCash")
if not HammerComms then
local Remote = Instance.new("RemoteEvent")
Remote.Parent = game.ReplicatedStorage
Remote.Name = "HAMMERCOMMS"
Remote:FireServer("ClientError")
end
if not Comms then
local Remote = Instance.new("RemoteEvent")
Remote.Parent = game.ReplicatedStorage
Remote.Name = "Comms"
Remote:FireServer("ClientError")
end
if not ShowGui then
local HammerComms2 = game.ReplicatedStorage:FindFirstChild("HAMMERCOMMS")
if not HammerComms2 then
local Remote = Instance.new("RemoteEvent")
Remote.Parent = game.ReplicatedStorage
Remote.Name = "HAMMERCOMMS"
Remote:FireServer("ClientError")
else
HammerComms:FireServer("ClientError")
end
end
if not ChatEvent then
local HammerComms2 = game.ReplicatedStorage:FindFirstChild("HAMMERCOMMS")
if not HammerComms2 then
local Remote = Instance.new("RemoteEvent")
Remote.Parent = game.ReplicatedStorage
Remote.Name = "HAMMERCOMMS"
Remote:FireServer("ClientError")
else
HammerComms:FireServer("ClientError")
end
end
if not updateCash then
local HammerComms2 = game.ReplicatedStorage:FindFirstChild("HAMMERCOMMS")
if not HammerComms2 then
local Remote = Instance.new("RemoteEvent")
Remote.Parent = game.ReplicatedStorage
Remote.Name = "HAMMERCOMMS"
Remote:FireServer("ClientError")
else
HammerComms:FireServer("ClientError")
end
end
end
I have also tried using other events as a fallback but that does not work when all of the events are deleted. I do not know how to solve this as this is the only known vulnerability in my game. The Event is pretty secure as it will only kick the player who fired the event. Comms can only be fired as it was originally used as fallback.