Hello! This is my first anti-cheat, which I made after an incident and reviewing common exploits. It’s mainly a server-sided character check, extends to walk speed and another layer with a client script that imitates the JumpWalkSpeed function (which blocks most common exploiters that rely on an interface).
Main ServerScript, parented under ModuleScript
Module = require(script.Parent)
--FUNCTIONS
local function IsWhitel(Player)
local whitelist = Module.whitelisted
for _,whitel in pairs (whitelist) do
if type(whitel) == "string" and string.lower(whitel) == string.lower(Player.Name) then
return true
elseif type(whitel) == "number" and whitel == Player.UserId then
return true
end
end
end
function scalechange(part, property, treshold)
local saveddefault = part[property].Value
part[property]:GetPropertyChangedSignal("Value"):Connect(function()
if part[property].Value > treshold then
--print (part.Parent, property, "changed")
part[property].Value = saveddefault
daechwita(part)
end
end)
end -- Scale Changes to Humanoid
function abilitychange(part, vlue, treshold1, treshold2, treshold3)
local saveddefault = part[vlue]
part:GetPropertyChangedSignal(vlue):Connect(function()
if part[vlue] > treshold1 or treshold2 or treshold3 then
--print (part.Parent, vlue, "changed")
part[vlue] = saveddefault
end
end)
end -- Changes to humanoid properties
function partcharremoved (char)
local r6parts = {"Head";"Torso";"LeftArm";"RightArm";"LeftLeg";"RightLeg";}
local r15parts = {"LowerTorso"; "UpperTorso"; "Head";
"LeftFoot";"RightFoot";"LeftLowerLeg";"RightLowerLeg";"LeftUpperLeg";"RightUpperLeg";
"LeftHand";"LeftLowerArm";"LeftUpperArm";"RightHand";"RightLowerArm";"RightUpperArm";
}
char.ChildRemoved:Connect(function(instance)
if char.Humanoid.RigType == Enum.HumanoidRigType.R15 then
for _,part in pairs (r15parts) do
if type(part) == "string" and string.lower(part) == string.lower(instance.Name) then
game:GetService("Players"):GetPlayerFromCharacter(char):LoadCharacter()
end
end
elseif char.Humanoid.RigType == Enum.HumanoidRigType.R6 then
for _,part in pairs (r6parts) do
if type(part) == "string" and string.lower(part) == string.lower(instance.Name) then
game:GetService("Players"):GetPlayerFromCharacter(char):LoadCharacter()
end
end
end
end)
end
--Running
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(character)
if IsWhitel(plr) then
return
else
local humanoid = character:FindFirstChildOfClass("Humanoid")
local primarypart = character.PrimaryPart
--Modify the treshold numbers at the end to your choice
if Module.HealthModifications then
abilitychange(humanoid, "MaxHealth", 100, 0, 0)
end
if Module.BodyPartMissing then
partcharremoved(character)
end
-- Comes with client imitation of abilitychange. Modify on the localscript too
if Module.JumpWalkProperties then
abilitychange(humanoid,"WalkSpeed",16,0,0)
abilitychange(humanoid,"JumpPower",50,0,60)
humanoid.Running:Connect(function(speed)
if speed > humanoid.WalkSpeed + 5 then
plr:LoadCharacter()
end
end)
local jumpwalkregulator = script.Parent:WaitForChild("JumpWalkSpeed"):Clone()
jumpwalkregulator.Name = ""; jumpwalkregulator.Parent = plr:WaitForChild("PlayerGui")
end
if Module.BodyScaling then
scalechange(humanoid,"HeadScale", 1)
scalechange(humanoid,"BodyWidthScale", 1)
scalechange(humanoid,"BodyDepthScale", 1)
scalechange(humanoid,"HeadScale", 1)
--[[local bodyscaleregulator = script.Parent:WaitForChild("BodyScale"):Clone()
bodyscaleregulator.Name = ""; bodyscaleregulator.Parent = plr:WaitForChild("PlayerGui")]]
end
-- These are modified on the Module, or is fine being left like so.
if Module.FakeScripts then
for count = 1, Module.FakeScriptAmount do
local fakescript = script.Parent:WaitForChild("DummyScript"):Clone()
fakescript.Name = ""; fakescript.Parent = plr:WaitForChild("PlayerGui")
end
end
end
end)
end)
Since this is my first attempt at overcoming cheats, I’d like to hear from the more experienced scripters on inefficiencies in my script and parts I can improve on. Thank you so much!