Patching an Exploit

Heya, how would I patch this script within my game? I’d like some help if that’s alright.
This is a Vehicle-Fly Exploit

local Speed = 50

local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")

local Player = Players.LocalPlayer
local Character = Player.Character

local HRP = Character:WaitForChild("HumanoidRootPart")
local Camera = workspace.CurrentCamera

local BodyVelocity = Instance.new("BodyVelocity", HRP)
BodyVelocity.Velocity = Vector3.new(0, 0, 0)
BodyVelocity.MaxForce = Vector3.new(9e9, 9e9, 9e9)

local BodyGyro = Instance.new("BodyGyro", HRP)
BodyGyro.P = 9e4
BodyGyro.MaxTorque = Vector3.new(9e9, 9e9, 9e9)

RunService.RenderStepped:Connect(function()
    local MoveX = 0
    local MoveY = 0
    local MoveZ = 0
    
    if UIS:IsKeyDown(Enum.KeyCode.W) then
        MoveZ = -10
    end
    
    if UIS:IsKeyDown(Enum.KeyCode.S) then
        MoveZ = 10
    end
    
    if UIS:IsKeyDown(Enum.KeyCode.A) then
        MoveX = -10
    end
    
    if UIS:IsKeyDown(Enum.KeyCode.D) then
        MoveX = 10
    end
    
    if UIS:IsKeyDown(Enum.KeyCode.W) or UIS:IsKeyDown(Enum.KeyCode.A) or UIS:IsKeyDown(Enum.KeyCode.S) or UIS:IsKeyDown(Enum.KeyCode.D) then
        BodyVelocity.Velocity = CFrame.new(HRP.Position, (HRP.CFrame * CFrame.new(MoveX, MoveY, MoveZ).Position)).LookVector * Speed
    else
        BodyVelocity.Velocity = Vector3.new(0, 0, 0)
    end
    
    BodyGyro.CFrame = Camera.CoordinateFrame
end)```

You need to add an anti-exploit script that detects fly exploits and prevents them. There are multiple forum posts on how to script this.

I recommend you should make a rubber banding anti cheat. or just detect a BodyGyro inside of the players character model

Example: dont actually use this

local plr = game.Players.LocalPlayer
local character = plr.Character

for i,gyro in pairs(character:GetDescendants()) do
  if gyro:IsA("BodyGyro", "BodyVelocity") then
   plr:LoadCharacter() -- for false positive prevention
end
end

this was wrote without being in studio so idk if this is correct.

This will only work in ClientSide making it AUTOMATICALLY VULNERABLE and bypassable in seconds & plr:LoadCharacter() doesn’t work in clientside

1 Like

You can make/get your own anti exploit, I recommend buying/making an Serversided anti exploit that detects FLY using raycasts.

Otherwise making/get an clientsided one but it makes it automatically vulnerable and very easy to bypass.

Could you link me one? I’d like to see some.

You could, as a temporary fix, remove network ownership of the humanoidrootpart from the player.

--When player gets into vehicle

Character.HumanoidRootPart:SetNetworkOwner(nil)

--When player gets out of vehicle

Character.HumanoidRootPart:SetNetworkOwner(Player)

(this is completely server-side)

If the player is in a vehicle then most anti-fly scripts will think they are on the ground, because the raycasts will just land on the vehicle.

well thats why i said dont use it. its an example, but yeah i know loadcharacter doesn’t work on client. Only works on backend server.

My anti cheat detects fly, cframefly, vehiclefly. vehicle fly does kinda work over it but after like 10 seconds it forces u to get out the vehicle and rubber bands you

That’s not bad idea, but Roblox servers often run on high latency, and making the vehicle which is player controlled server-side could result in some lags and bad gameplay experience for the player.
Just adding in case the person didn’t know consequences of such solution.

1 Like

i think this can help you. Anti-Exploit Script | Advice / Help

Hello @Vephinox

This is an easy function (On Client) so exploit can delete it but it works!

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
repeat task.wait() until player.Character.Parent

character.HumanoidRootPart.ChildAdded:Connect(function(Obj)
	if Obj:IsA("BodyGyro", "BodyVelocity") then
		player:Kick("Stop Exploiting")
	end
end)

It won’t work on the server because the exploiters are adding the BodyGyros on the client-side so the server won’t see it.

yeah so im pretty sure you have to detect if the local script gets deleted on the players model then you kick them.

I see well thanks for the help if anyone would like to shoot me a dm on discord to assist please do ( Orzid#7060 )