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.
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
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?
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
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?
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.
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)
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:
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
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.