So, this is my anti-cheat script. Not much explaining to do really, but thanks for any feedback!
player.CharacterAdded:Connect(function(char)
wait(3)
local firstCF = char:WaitForChild("HumanoidRootPart").CFrame
local lastY = char.HumanoidRootPart.Position.Y
local antiCheats = 0
local stillInAir = false
local falling = false
local lastCF
local humanoid = char:WaitForChild("Humanoid")
humanoid.FreeFalling:Connect(function()
falling = true
end)
spawn(function()
while wait(0.8) do
if game.ReplicatedStorage.Values.Game.Value == true then
if char:FindFirstChild("HumanoidRootPart") then
lastCF = char.HumanoidRootPart.CFrame
if lastCF then
if (lastCF.Position - char.HumanoidRootPart.Position).Magnitude >= 100 then
if not player:FindFirstChild("Tele") then
char.HumanoidRootPart.CFrame = lastCF
end
end
end
if (lastY-char.HumanoidRootPart.Position.Y) <= -25 then
if not player:FindFirstChild("Tele") then
char.HumanoidRootPart.CFrame = lastCF
end
end
if humanoid.FloorMaterial == Enum.Material.Air then
if stillInAir == false then
if falling == false then
stillInAir = true
end
else
if falling == false then
antiCheats += 1
if antiCheats == 5 then
antiCheats = 0
char.HumanoidRootPart.CFrame = firstCF
else
char.HumanoidRootPart.CFrame = lastCF
end
stillInAir = false
end
end
else
falling = false
end
end
if char:FindFirstChild("HumanoidRootPart") then
lastY = char.HumanoidRootPart.Position.Y
lastCF = char.HumanoidRootPart.CFrame
end
end
end
end)
spawn(function()
while wait(120) do
antiCheats = 0
end
end)
end)
end)