Hello devs.
Today I was working on my game and i started making anti exploit.
I’ve just done it and i want too see if its going to work.
The anti exploit includes:
1 script
1 module script
Here is the code
Script :
local PartChecker = require(script.PartChecker)
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Char)
local HRP = Char:WaitForChild("HumanoidRootPart")
local Hum = Char.Humanoid
local function WalkJumpAntiExploit()
if Player.Character then
if Hum then
Hum.WalkSpeed -= 0.1
Hum.WalkSpeed += 0.1
Hum.JumpPower -= 0.1
Hum.JumpPower += 0.1
end
end
end
Hum.Running:Connect(function(speed)
WalkJumpAntiExploit()
end)
Hum:GetPropertyChangedSignal("Jump"):Connect(function()
WalkJumpAntiExploit()
end)
game:GetService("RunService").Heartbeat:Connect(function()
WalkJumpAntiExploit()
end)
HRP.Touched:Connect(function(hit)
if not hit:IsDescendantOf(Char) then
if hit.CanCollide == true then
local success,err = pcall(function()
local IsInside,percentage = PartChecker.IsPartInsidePart(HRP,hit)
if IsInside == true then
Player:LoadCharacter()
end
end)
end
end
task.wait(0.2)
if not hit:IsDescendantOf(Char) then
if hit.CanCollide == true then
local success,err = pcall(function()
local IsInside,percentage = PartChecker.IsPartInsidePart(HRP,hit)
if IsInside == true then
Player:LoadCharacter()
end
end)
end
end
end)
Hum:GetPropertyChangedSignal("MoveDirection"):Connect(function()
if game.Players:FindFirstChild(Player.Name) ~= nil then
if Hum:GetState() == Enum.HumanoidStateType.PlatformStanding then
local ray = workspace:Raycast(HRP.Position,HRP.CFrame.UpVector * -5)
if Hum.FloorMaterial == Enum.Material.Air and ray == nil and HRP.Velocity.magnitude == 0 then
Player:LoadCharacter()
end
end
if HRP then
if Hum:GetState() == Enum.HumanoidStateType.Swimming then
local min = HRP.Position - (HRP.Size / 2)
local max = HRP.Position + (1 * HRP.Size)
local region = Region3.new(min,max):ExpandToGrid(4)
local material = workspace.Terrain:ReadVoxels(region,4)[1][1][1]
if material ~= Enum.Material.Water and Hum:GetState() == Enum.HumanoidStateType.Swimming then
Hum:ChangeState(Enum.HumanoidStateType.FallingDown)
task.wait()
if Hum:GetState() == Enum.HumanoidStateType.Swimming then
Player:Kick("Bruh u cant even swim in this game")
end
end
end
end
end
end)
end)
end)
Module script for collision detection:
local module = {}
function CreateExo(part)
local Positions = {
[1] = Vector3.new(part.Size.X/2,part.Size.Y/2,part.Size.Z/2),
[2] = Vector3.new(-part.Size.X/2,part.Size.Y/2,-part.Size.Z/2),
[3] = Vector3.new(part.Size.X/2,part.Size.Y/2,-part.Size.Z/2),
[4] = Vector3.new(-part.Size.X/2,part.Size.Y/2,part.Size.Z/2),
[5] = Vector3.new(part.Size.X/2,-part.Size.Y/2,part.Size.Z/2),
[6] = Vector3.new(-part.Size.X/2,-part.Size.Y/2,-part.Size.Z/2),
[7] = Vector3.new(part.Size.X/2,-part.Size.Y/2,-part.Size.Z/2),
[8] = Vector3.new(-part.Size.X/2,-part.Size.Y/2,part.Size.Z/2),
}
if part:IsA("Part") then
if part.Shape ~= Enum.PartType.Block then
Positions = {
[1] = Vector3.new(0,part.Size.Y/2,0),
[2] = Vector3.new(0,-part.Size.Y/2,0),
[3] = Vector3.new(part.Size.X/2,0,0),
[4] = Vector3.new(-part.Size.X/2,0,0),
[5] = Vector3.new(0,0,part.Size.Z/2),
[6] = Vector3.new(0,0,-part.Size.Z/2),
}
end
end
local atts = {}
for i,v in pairs(Positions) do
local att = Instance.new("Attachment",part)
att.Position = v
att.Name = "_[att]_"..i
table.insert(atts,att)
end
return atts
end
function module.IsPartInsidePart(part1,part2)
local Exo = CreateExo(part1)
local Checker = Instance.new("Attachment",part2)
local IsInPart = true
local AreIn = #Exo
for _,v in pairs(Exo) do
Checker.WorldPosition = v.WorldPosition
v:Destroy()
if math.abs(Checker.Position.X) > part2.Size.X/2 then IsInPart = false AreIn -= 1 continue end
if math.abs(Checker.Position.Y) > part2.Size.Y/2 then IsInPart = false AreIn -= 1 continue end
if math.abs(Checker.Position.Z) > part2.Size.Z/2 then IsInPart = false AreIn -= 1 continue end
end
return IsInPart, AreIn/#Exo * 100
end
return module
Feel free to use it if its a good one. Supports
- Anti speed and jump power change
- Prevents swimming exploit (really sensitive)
- Prevents flying