--- server script
local players = game:GetService("Players")
local rs = game:GetService("ReplicatedStorage")
local runservice = game:GetService("RunService")
local sss = game:GetService("ServerScriptService")
local kpl = rs:FindFirstChild("randomremote")
local check = rs:WaitForChild("sizecheckclient")
local checkall = rs:WaitForChild("sizecheckall")
local module = require(sss.functions)
local running = {}
local function scheck(character)
local plr = players:GetPlayerFromCharacter(character)
if not plr then return end
if running[plr] then return end
running[plr] = true
while plr do
task.wait(3)
local plsizetable = checkall:InvokeClient(plr)
for _,foundplayer in pairs(players:GetChildren()) do
for name,size in pairs(plsizetable[foundplayer.Name]) do
local cheating = module.scfa(plr,foundplayer,name,size)
if cheating then
plr:Kick("cheating")
running[plr] = nil
break
end
end
end
end
running[plr] = false
end
a = game.Players.PlayerAdded:Connect(function(plr)
if plr.Character then
task.spawn(scheck, plr.Character)
end
plr.CharacterAdded:Connect(function(character)
task.spawn(scheck, character)
end)
end)
--- module script
local module = {}
local limbs = {
["Head"] = Vector3.new(2,1,1),
["Torso"] = Vector3.new(2,2,1),
["Right Leg"] = Vector3.new(1,2,1),
["Left Leg"] = Vector3.new(1,2,1),
["Right Arm"] = Vector3.new(1,2,1),
["Left Arm"] = Vector3.new(1,2,1),
["HumanoidRootPart"] = Vector3.new(2,2,1)
}
local plrs = game:GetService("Players")
local runservice = game:GetService("RunService")
function module.sc(limbname,cheatingsize)
for name,expectedsize in pairs(limbs) do
if limbname == name then
if (cheatingsize - expectedsize).Magnitude > 0.1 then
print("cheat:", limbname, cheatingsize)
return true
end
end
end
print("no cheat")
return false
end
function module.scfa(cheatingplayer,anyplayer,limbname,cheatingsize)
for name,expectedsize in pairs(limbs) do
if limbname == name then
if (cheatingsize - expectedsize).Magnitude > 0.1 then
print("cheater: ".. cheatingplayer.Name.. " sees " .. anyplayer.Name.."'s limb: ".. limbname.." as size:", cheatingsize)
return true
end
end
end
print("no cheat")
return false
end
return module
--- local script
local players = game:GetService("Players")
local player = players.LocalPlayer
local rs = game:GetService("ReplicatedStorage")
local bs = rs:WaitForChild("sizecheckclient")
local bsa = rs:WaitForChild("sizecheckall")
bs.OnClientInvoke = function()
local char = player.Character
if not char then return {} end
local sizes = {}
for _,v in pairs(player.Character:GetChildren()) do
if v:IsA("BasePart") then
sizes[v.Name] = v.Size
end
end
return sizes
end
bsa.OnClientInvoke = function()
local chart = {}
for _,v in pairs(players:GetPlayers()) do
if v.Character then
chart[v.Name] = {}
for _,v2 in pairs(v.Character:GetChildren()) do
if v2:IsA("BasePart") then
chart[v.Name][v2.Name] = v2.Size
end
end
end
end
return chart,player
end
this is a basic size check anti-cheat that ive made for my game, the local script gives size values to the server and server uses module functions to check for the size differences and depending on that kicks the player.
however i do believe we can improve this code or atleast get some tips on how to improve it, because i am only at mediocre level of scripting i believe there is people that can help me improve.
the part that i want to improve is making it more reliable by conducting server checks rather than rely on client to get the data.
edit: server script and module is in serverscriptservice while local script is in playerscripts