Anti Cheat [Fly, Teleportation, JumpPower, WalkSpeed] (Server Sided)

Roblox Server Sided Anti Cheat [Fly, Teleportation, JumpPower, WalkSpeed] (Search Engine)

Here’s a quick little script I wrote together for my future portfolios, free to use.

Note: It’s not meant to be pretty and if you find any problems comment on the thread and I’ll fix it.

Server Script (Parent Of Configuration Module)

-- // Written By .sinkz / Sinkl0z
-- // Variables
local Configuration = require(script.Configuration)

local PlayerFlags = {}
local PlayerThreads = {}

local OldPlayerPositions = {}
local NewPlayerPositions = {}

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		-- // Begin
		PlayerFlags[Player] = 0
		local HumanoidRootPart = Character.HumanoidRootPart
		
		-- // Create a Player specific thread for each player in the server upon join
		PlayerThreads[Player] = task.spawn(function()
			
			-- // Short yield to make sure Player loaded
			task.wait(3)	
			
			while true do
				
				-- // Store old Positions
				OldPlayerPositions[Player] = {
					X = HumanoidRootPart.Position.X, 
					Y = HumanoidRootPart.Position.Y,
					Z = HumanoidRootPart.Position.Z,
				}
				
				task.wait(0.5)
				
				-- // Store new Positions
				NewPlayerPositions[Player] = {
					X = HumanoidRootPart.Position.X,
					Y = HumanoidRootPart.Position.Y,
					Z = HumanoidRootPart.Position.Z,
				}
								
				-- // Y Position changes
				if 
					NewPlayerPositions[Player].Y - OldPlayerPositions[Player].Y > 0 and
					math.abs(NewPlayerPositions[Player].Y - OldPlayerPositions[Player].Y) >= Configuration.Numbers.JumpHeightLimit + Configuration.Numbers.JunpHeightThreshold
				then
					HumanoidRootPart.CFrame = CFrame.new(OldPlayerPositions[Player].X, OldPlayerPositions[Player].Y, OldPlayerPositions[Player].Z)		
					PlayerFlags[Player] += 1
				end
				
				-- // X - Z Position changes
				if 
					math.abs(NewPlayerPositions[Player].X - OldPlayerPositions[Player].X) >= Configuration.Numbers.WalkSpeedLimit + Configuration.Numbers.WalkSpeedThreshold or 
					math.abs(NewPlayerPositions[Player].Z - OldPlayerPositions[Player].Z) >= Configuration.Numbers.WalkSpeedLimit + Configuration.Numbers.WalkSpeedThreshold 
				then
					HumanoidRootPart.CFrame = CFrame.new(OldPlayerPositions[Player].X, OldPlayerPositions[Player].Y, OldPlayerPositions[Player].Z)
					PlayerFlags[Player] += 1
				end
				
				-- // Punishment
				if PlayerFlags[Player] >= Configuration.Numbers.MaximumFlags then
					if Configuration.Booleans.KickPlayer then
						-- // Kicks Player 
						Player:Kick("Abnormal Position Changes")
					else
						-- // Kills / Resets Player 
						if Character.Head then
							Character.Head:Destroy()
							PlayerFlags[Player] = 0
						else
							Character.Parent = nil
							task.wait(2)
							Character.Parent = workspace
							PlayerFlags[Player] = 0
						end			
					end
				end	
				
				-- // Reset stored Positions 
				table.clear(OldPlayerPositions[Player])
				table.clear(NewPlayerPositions[Player])
			end
		end)
	end)	
end)

game.Players.PlayerRemoving:Connect(function(Player)
	-- // Clear all Player specific stored values (Important to prevent memory leaks)
	PlayerFlags[Player] = 0 
	NewPlayerPositions[Player] = 0
	OldPlayerPositions[Player] = 0
	
	task.cancel(PlayerThreads[Player])
	PlayerThreads[Player] = nil
end)

ConfigurationModule(Child Of Server Script)

local ConfigurationModule = {
	
	Numbers = {
		WalkSpeedLimit = 16,
		WalkSpeedThreshold = 2,

		JumpHeightLimit = 50,
		JunpHeightThreshold = 2,

		MaximumFlags = 6,
	},
	
	Booleans = {
		KickPlayer = true,
	},
	
}

return ConfigurationModule
18 Likes

Isn’t it better to crash the player? I am pretty sure kicking can be bypassed.

4 Likes

5 Likes

As you can see in his screenshot it says “Server Sided”, players cannot bypass kicks being called from the Server itself

8 Likes

exploiters can’t bypass server kicks, they can only bypass client kicks

3 Likes

I thought they could override a function eitherway?
guess not.

They can override the function, but that only applies client-sided

3 Likes

Well thanks! you learn something new every day.

2 Likes

Ayy SinkZ is finally trying out serverside anticheats.
:smiley:

5 Likes

Had to give it a shot after all, got a little bit tired of client sided anti cheats!

4 Likes

Is it anti-fly or can you still float/fly slowly? (I’m on my phone but I’ll test later)

3 Likes

It’s meant to be a anti fly but I hadn’t thought about the fact that it’d probably get bypassed by floating slowly.

Since it doesn’t raycast and it only compares the last looped position with the current position.

3 Likes

Yeah the Y check is pretty sad.
Floating slowly up and Flying at the characters walkspeed seems to work fine.

1 Like

I’ll make a patch for that once I’ve got the time on my hands.

2 Likes

I’m new around anticheats here so if I had an admin system would it recognise it’s commands and kick an admin? or is it moreover aimed at an external source like injections.

1 Like

I’m not sure if I understand what you’re asking here? Are you wondering if admin system’s main porpouse is to detect Injections?

2 Likes

as in would the anticheat consider an admin command like :fly me or :speed me as a cheat and swing into action, basically just asking if it works with admin commands.

1 Like

Oh, yes it would flag admin commands as exploits at its current state. It’d need a lot of modification to work with admin commands.

I might be able to make a admin command system if you’d like me too?

No that’s fine lol, you don’t need to, I was just wondering how it worked, thanks for clarifying. I’ve been pondering around anticheat posts for the some time now trying to grasp the idea.

1 Like

Im probably late but you could just add a white list and before kicking the player check if he is on it, if he is dont kick him