Prevent remote events from being deleted by exploiters

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.

There’s no good way to prevent something from being deleted on the client. How exactly is this a vulnerability in your game?

It can completely disable communication with the client from the server side anti cheat

I would say don’t worry. If an exploiter accesses client data, it would most likely only be their own. ServerSided data is more likely to get exploited than client, because exploiters can only access their client data.

So currently if the exploiter does not delete all of the events the server kicks them. And if all are deleted the exploiter has made his own game unplayable but not completely. Should I just add a small client side kick? I know it can be bypassed but they can’t do anything in that half kicked state.

No matter what you do the player will have full access to everything client sided. Server validation is the only way to detecf exploiters. You gotta find a setup that ONE makes it easy for the server to validate input and TWO gives the exploiter as little control over outcomes

1 Like

Theres no way you can prevent every exploit but within your game there should be things the player does that should never be possible. Either they instantly teleport 10000 studs or are flying upward at a constant speed. You can detect this with the server and respond accordingly