Feedback on anti-exploit

I have been working today on an anti exploit system for WalkSpeed and Teleportation. I have created a place file if you want to download it, but I will post the code here also.

I would like to know if this code is efficient, meaning there are no memory leaks or oversights and if it has been well laid out. Like, the way the code is presented etc. Not comments but, readability.

Download: Exploit Redemption!.rbxl (33.9 KB)

[Server] Script:

local ServerStorage = game:GetService("ServerStorage")

local ModuleScripts = ServerStorage.ModuleScripts

local ModuleScript = require(ModuleScripts.ModuleScript)

local Initialize = function()
	ModuleScript:Initialize()
	return
end
Initialize()

[Server] ModuleScript:

local Players = game:GetService("Players")

local ModuleScript = require(script.ModuleScript)

local Module = {
	Players = table.create(1)
}

Module.PlayerAdded = function(Player)
	getfenv(1).self = Module
	local PlayerDictionary = ModuleScript.new(Player)
	coroutine.resume(coroutine.create(PlayerDictionary.Initialize), PlayerDictionary)
	self.Players[Player.Name] = PlayerDictionary
	return
end

Module.PlayerRemoving = function(Player)
	getfenv(1).self = Module
	local PlayerDictionary = self.Players[Player.Name]
	coroutine.resume(coroutine.create(PlayerDictionary.Terminate), PlayerDictionary)
	self.Players[Player.Name] = nil
	return
end

Module.Initialize = function(self)
	Players.PlayerAdded:Connect(self.PlayerAdded)
	Players.PlayerRemoving:Connect(self.PlayerRemoving)
	return
end

return Module

[Server] ModuleScript2:

local Module = {}
Module.__index = Module

Module.new = function(Player)
	return setmetatable(
		{
			Player = Player,
			PlayerRemoving = false
		},
		Module
	)
end

Module.Update = function(self)
	if self.FormerPosition then
		local DeltaPosition = self.HumanoidRootPart.Position - self.FormerPosition
		if math.floor(math.sqrt(math.pow(DeltaPosition.X, 2) + math.pow(DeltaPosition.Z, 2))) > self.Humanoid.WalkSpeed then
			self.Player:Kick("Vermin, as a requisite; must be disposed of. Ablute of exploits!")
			self.PlayerRemoving = true
		end
	end
	self.FormerPosition = self.HumanoidRootPart.Position
end

Module.Terminate = function(self)
	if not self.PlayerRemoving then
		self.PlayerRemoving = true
	end
	task.wait(1)
	table.clear(self)
	self = nil
	return
end

Module.Initialize = function(self)
	local Character = self.Player.Character or self.Player.CharacterAdded:Wait()

	local Humanoid = Character:WaitForChild("Humanoid")
	local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

	self.Humanoid = Humanoid
	self.HumanoidRootPart = HumanoidRootPart
	task.wait(math.exp(1))
	while true do
		if not self.PlayerRemoving then
			self:Update()
		else
			break
		end
		task.wait(1)
	end
end

return Module

Personally I am looking for an alternative to

getfenv(1).self = Module

because I think it looks ugly and does not compliment the flow. Anyways here is a place for testing

https://www.roblox.com/games/8089685193/Exploit-Redemption

I hope for at least some positive feedback
3 Likes

the game is private so I can’t play it but I love the code a lot

1 Like