Anti-Exploit | Flinging and BodyForces

Hello, I’m trying to prevent my game from being exploited by a script that flings players by using a high speed body force object in someones root or torso, which ends up flinging them. I know I can disable collisions, but I would like to keep them on for my game.

A example of how it looks (found this online): https://gyazo.com/9fd4b435616ed6c6d46691b22b5f9ba5

I was wondering how to defend against this particular method, thanks!

6 Likes

Use VectorForce object and load on client.

Um, could you elaborate more on what you mean?

Am I misunderstood? Are you trying to fling players or prevent players from being flinged?

1 Like

Well you can keep a script that constanly checks if a body force was added to the root/torso, which might still cause a problem since the exploiter may find the local script and destroy it, since he added the force from the client in the first place thus it only shows up in the client and can’t be checked using a serverscript.

Or you can cancel out the force that the exploiter added, using another BodyForce

1 Like

Well if they added a BodyForce to a players parts, and then it made them spin, wouldn’t it replicate due to NetworkOwnership? And even if it didn’t replicate, then the other players wouldn’t be flinged since the torso that’s spinning wouldn’t have replicated the spinning. So using that as a example of concept, would you be able to just constantly check the Parts velocity on serverside with a heartbeat or render loop?

1 Like

You can perform checks on the server to see if the character’s HumanoidRootPart / Torso has a high velocity, then counter that by using a BodyForce with the same magnitude as the root’s velocity, but in the opposite direction. Basically, what @starmaq suggested

2 Likes

Oh alright. How in specific would I check the part’s velocity, like would you do
if humanoidrootpart.Velocity == Vector3.new(50,0,50) then
plr:Kick(“bad”)
end?
Or would I do something else?

1 Like

You would check the vector’s magnitude and compare it to a specified number. The magnitude of Velocity is its speed:

if hrp.Velocity.Magnitude >= 60 then
   -- player is moving at a speed of 60 studs/s or more
   -- counter with another force in the opp. direction 
end
7 Likes

After some experimentation, if you set the density of other players objects in a local script to 0.01, player collission will replicate but other players cannot affect your position or fling you. The exploiter will see the player being fung, but it will not replicate to the victim or other clients.

12 Likes

Oh alright, thanks a lot guys!

30chars30chars30chars30chars

2 Likes

You could disable all collisions between a player by using the Physics service
example in code:

local PhysicsService = game:GetService("PhysicsService")
local PlayerCollisionGroupId = PhysicsService:CreateCollisionGroup("Players")

PhysicsService:CollisionGroupSetCollidable("Players", "Players", false)

game.Players.PlayerAdded:Connect(function(player)
  local function characterAdded(character)
      for _, part in next, character:GetChildren() do
          if part:IsA("BasePart") then
              part.CollisionGroupId = PlayerCollisionGroupId 
          end
      end
  end
  if player.Character then
      characterAdded(player.Character)
  end
  player.CharacterAdded:Connect(characterAdded)
end)
3 Likes

With this code body parts or accessories that are added after it is run (as well as non-direct descendants) will not be added to the collision group. I recommend using this to alleviate these issues if you’re going to disable collisions between players:

(sent the wrong link initially oops)

1 Like

Accessories can not collide by default, since they have the CanCollide property set to false, but you’re right about any other descendants being added later on.
What I presented was a simple solution, not a “100% this is it” solution

Please use Ben’s code if you’re adding any BaseParts to your character, If you aren’t then the code I provided should be more than enough for your needs

You cant detect if someone added BodyForce to his Character. The best way to detecting this is a making ban system from serverside. and a RemoteEvent for banning people which is exploiting.

Client ----> (Detect BodyForce) ----> Fire RemoteEvent ----> Server ----> Ban with DataStore

The exploiters can return the RemoteEvent nil. You need a little bit more security. If you dont know how to do that, Reply me.

The Function:

local Players = game:GetService("Players")

local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

SearchBodyForces = function(Folder)
    Folder = Folder:GetChildren()

    if #Folder > 0 then
        for _,v in pairs(Folder) do
            if v:IsA("BodyForce") then
                return v
            end
            SearchBodyForces(v)
        end
    end
end
1 Like

Also checking Velocity might be reason of false bans/kicks. I dont prefer using Velocity because people can be flew by a glitch.

Instead of banning, you could annoy the exploiters by resetting their velocity back to 0 upon detection server-side. This also won’t ban legitimate players who got glitched. It might actually be helpful.

I prefer using ban because the exploiters will try to bypass the anti-exploit. If you dont want much false bans, you can make a chance value. If the player’s chance is the maximum limit, the player can get banned.