Creating an anti-Tabglitch anticheat

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    I am trying to create an antiexploit for the Tabglitching client issue, this is a bug where, upon holding right click on the window bar, freezes your game and character, making your character freeze midair whenever needed.

  2. What is the issue?
    I have a popular PVP game where players hit each other off an island, and being able to float midair and prevent any damage done to you is a pretty big exploit and it is taken advantage of a lot.

  3. What solutions have you tried so far?
    I have been trying to make an antiexploit for this for a while, and i thought of a solution where, when a player has a random lag spike, it sets their networkownership to the server so the server can handle physics and make them automatically fall. This doesnt seem to work however, and just makes you lag for a second or two.


local character = script.Parent
local player = game.Players:GetPlayerFromCharacter(character)

local humanoid = character:WaitForChild("Humanoid")
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local antiTabGlitch = coroutine.create(function()
	while true do
		local oldPosition = humanoidRootPart.Position
		local oldVelocity = humanoidRootPart.Velocity
		task.wait(1.5) -- Cooldown
		local currentPosition = humanoidRootPart.Position
		local currentVelocity = humanoidRootPart.Velocity 
		if oldPosition == currentPosition and oldVelocity ~= Vector3.new(0, 0, 0) and currentVelocity ~= Vector3.new(0, 0, 0) and tonumber(player:GetNetworkPing() * 2000) < 300 then
			if character.Humanoid.Health == 0 then return end
			local character = player.Character
			-- Set network ownership of character baseparts to server
			for _, part in ipairs(character:GetDescendants()) do
				if part:IsA("BasePart") then
					part.Anchored = false
					part:SetNetworkOwner(nil)
				end
			end
			print("start antitab")
			-- Wait for 2 seconds
			wait(2)
			print("end antitab")
			-- Bring network ownership back to client
			for _, part in ipairs(character:GetDescendants()) do
				if part:IsA("BasePart") then
					part:SetNetworkOwner(player)
				end
			end
		end
	end
end)
wait(5)
coroutine.resume(antiTabGlitch)
character.Humanoid.Died:Connect(function()
	coroutine.close(antiTabGlitch)
end)

please help all you can, this is a big problem for my game.

2 Likes

I don’t think setting the network ownership counters the tab glitching, I tried setting it beforehand and tab glitched, but the character didn’t fall.

2 Likes

Hmm i think you create a system that checks if there is anything under you and if there still is nothing after 20 second kill the player. Also I think parallel Lua would make the raycasting run smother. (Correct me if I’m wrong)

1 Like

the problem with this is that the player is midair a lot since its a floating island map, so this will 100% cause false positives.

1 Like

You could check if there’s nothing under you, and if the velocity of the player is 0. That would mean they’re just floating in the air. That’s if their velocity is set to (0, 0, 0) when they’re stuck with this glitch.

1 Like

the thing is, even if that would work, i dont want to make the player just die ; majority of my community likes tabglitching, but it makes it harder for new players since they most likely dont know the bug. I am just trying to make it simply not work so the community doesnt go crazy, since it would cause less rage than simply dying.

1 Like

Hello, so I have found out that tab glitching actually stops tick() so you can do something like this to prevent it:

-- define localplayer
local players = game:GetService("Players")
local localplayer = players.LocalPlayer

-- checkTick(lastTick: number): number
function checkTick(last: number): number
	return tick() - last
end

-- main anticheat
while task.wait() do
	-- get the new tick
	local new = tick()
	--  wait 1 second
	task.wait(1)
	-- calculate the new tick with the older tick thats called "new"
	local calculated = checkTick(new)
	-- check if last script runtime tick is bigger than "calculated" (sorry i didnt know how to say this)
	if calculated >= 1.5 then -- you can edit the 1.5 to a  lower value so it detects the tab glitch faster, but might cause false detections
		-- your punishment here
		-- for me i'd rather to kick the player for tab-glitching
		localplayer:Kick("You have been kicked for tab glitching.")
	end
end

This worked for me.
Place this as a localscript in ReplicatedFirst or StarterPlayer → StarterCharacterScripts

2 Likes