Hello, I’m trying to make an anti Infinite Jump (server sidded) and I’d need a bit of help starting if someone could help me.
Never made one, but I had a couple of ideas (that may or may not work, I’m open to criticism)
- Check if they have an object to jump off of whenever they jump
- Scan the position of their HumanoidRootPart to check for anything suspicious, as some scripts might set the position instead of using the humanoid Jump
- (not the best idea at all but worth a try I guess) Put invisible ceiling blocks that detect if a player has hit it
Based off it, if the special item make you jump, use a remote to gives the player a value when he use this item. Then just check if the player has the value or not.
Also, you can do one thing. There is a value when the humanoid is jumping. Just check x times when this value become true.
Hi, I have some scripts that can prevent them.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid.StateChanged:Connect(function(old, new) -- This is when the player jumps and jumps again in the air.
if old == Enum.HumanoidStateType.Jumping and new == Enum.HumanoidStateType.Jumping then
player:Kick("Cheating is not allowed here.")
end
end)
humanoid.StateChanged:Connect(function(old, new) -- This is when the player falls down and jumps in the air.
if old == Enum.HumanoidStateType.Freefall and new == Enum.HumanoidStateType.Jumping then
player:Kick("Cheating is not allowed here.")
end
end)
This is client-side script but if you wish making them in server-side script, use RemoteEvents.
If you can’t detect yourself cheat so go to this tutorial.
This is the most effective way that you can prevent exploiters from cheating. There are two possibilities that exploiters can double jump by, These are when
- They are free-falling
- They are jumping and jumping again.
Hi!
I think @EmeraldLimes gave you an accurate idea. You should check last Y-position of the player. The code I’m posting below involves raycasting to check Y-axis height of the humanoid root part in the world, and is pretty accurate, but is of course not a complete anti-exploit. It doesn’t cover horizontal teleportation, seat flight exploits etc. This is solely intended to prevent high jump. You also have to cover cases where player is, for instance, flying a plane or running fast.
@Boustifail suggested checking jump requests. That’s a reasonable idea, but will rarely work with more advanced exploits, since cheaters can jump without pressing space or setting that property to true. For example, they can insert new BodyVelocity, which will result in their character flying, but without triggering .Jump event.
This case was covered by @ProBaturay, who gave a reasonable idea as well, but script is unfortunately client-sided, meaning exploiters can effortlessly override those checks by disabling the whole script.
Most decent anti-cheat exploits perform server-side checks. Those are of course a little more performance demanding, but work well, and make cheaters’ jobs significantly harder. There are multiple ways one can prevent high jump and other movement exploits. The following, again, uses raycasting, which is pretty solid way to carry out security checks, although humanoid.FloorMaterial checking can also be implemented as an alternative.
local ALLOWED_ADDED_JUMP_HEIGHT = 100 -- studs
local rootParts = {}
local lastMagnitude = {}
local _humanoid
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
rootParts[player.UserId] = character:WaitForChild("HumanoidRootPart")
end)
end)
game:GetService("Players").PlayerRemoving:Connect(function(player)
rootParts[player.UserId] = nil; lastMagnitude[player.UserId] = nil
end)
while (true) do
for userId, root in pairs(rootParts) do
_humanoid = root.Parent.Humanoid
-- Cast a ray with allowed magnitude downwards.
local raycastResult = workspace:Raycast(
root.Position,
Vector3.new(0,-(_humanoid.JumpHeight + _humanoid.HipHeight + ALLOWED_ADDED_JUMP_HEIGHT),0)
)
-- If ray didn't hit anything, player is most likely moving too high above the ground.
if (not raycastResult) then
-- Last check to see whether player is falling.
if (root.Position.Y > lastMagnitude[userId]) then
root.Parent.Head:Destroy() -- Decide yourself what to do here.
end
end
lastMagnitude[userId] = root.Position.Y
end
-- More frequent checks are more accurate, but much more demanding as well.
wait(.7)
end
EDIT Remember, this is a sample code for you to understand, and should be polished as well as modified to cover all cases in order to be actually used in games.
Good idea, just remember to not make it a descendant of the Player.Character
, as an exploiter could destroy the value
Not necessary, you don’t need a LocalScript
to get the/a Player object
I personally think @EssenceExplorer has the best idea here so far, so you should do as he suggested
This is a small idea I had a few months ago:
You could RayCast from the character to the floor to check if they’re in a position which seems to be abnormal, if the player is in the air for too long, then detect it as hacking. Another thing could be checking if the Y axis of that position keeps increasing, each time the Y axis increases, a value would increase, that value decreases over-time, if that value goes over a limit, it would be detected as hacking.
I also recommend you to check ForbiddenJ’s open-sourced Anticheat, in the thread he explains how the Anticheat works, and I’m pretty sure it does have a way to detect when someone is infinite jumping, so I recommend you to take a look at it.
Thanks for reading.
You gave me an idea, it might work.
Yea, thats a good idea but if I would invisible blocks, lets say someone gets fling and touches that that wouldn’t be great butt the rest I will try.
humanoid.StateChanged:Connect(function(old, new).
if old == Enum.HumanoidStateType.Freefall and new == Enum.HumanoidStateType.Jumping then
player:Kick("Cheating is not allowed here.")
end
end)
This worked, thank you!
This script is prone to exploiters. I mean, if they wish they can change or disable the script, as @EssenceExplorer mentioned above. But you can sustain your script with some of the scripts stored in ServerScriptService
, it will detect if the exploiter is disabling or removing it.
local list = {}
while true do
wait(5)
table.clear(list)
for _, player in pairs (game:GetService("Players"):GetChildren()) do
table.insert(list, player)
end
local function kickPlayer(player)
local playerGUI = player:WaitForChild("PlayerGui")
local DoubleJump = playerGUI:FindFirstChild("DoubleJumpScript")
local DoubleJumpDisabled = DoubleJump.Disabled
if not DoubleJump or DoubleJumpDisabled == true then
player:Kick("You have been kicked due to exploit.")
end
end
table.foreach(list, kickPlayer)
end
I don’t know if this works.
Haxors could destroy values but it still is inside of him since he can destroy it only locally. If the server check the value, it will still be here.
Actually, since the character is controlled by the client (or some other reason), roblox gives network ownership of the character to the client, thus allowing the client to make limited changes (including deleting descendants of the character) to the character, which will reflect on server.
Here’s a link to network ownership if you want to check it out
That is true, however, such client-side checking approach presents an obstacle almost negligible for an exploiter.
Since clients hold network ownership over their characters, server can detect when player removes a certain part (not insert). If I were to check whether animate
script is present in game on server and remove it on client, the server would detect changes.
Nevertheless, exploiter could simply disable the script, and changes wouldn’t be visible to anyone else. Values such as script.Disabled
status do not replicate. There are only certain exceptions that do replicate with filtering enabled (FE), which are listed in the image I’m appending.
@ProBaturay had a good idea, which sadly doesn’t work, because .Disabled property doesn’t replicate. Furthermore, even if it did work, clients would find alternative ways to disable script functionality, e.g. disconnect active .StateChanged
connection. The saying “my machine, my rules” describes the issue almost perfectly.
That’s the reason why exploits are so hard to patch, why they exist in the first place, and why all the solid anti-exploits are installed on the server. Adding client-side security scripts as side-kicks is indeed useful sometimes, but in this case ineffective.
EDIT @EmeraldLimes I am fully aware that you understand replication and client-server model. This post is meant to be an extention of yours. Your post was not confusing at all.
Have a great day!
I am aware of the limitations of what an exploiter can do with FE and network ownership, but thank you for pointing that out. I meant for the checks to be made on the server, but I didn’t specify, sorry about the confusion. Good point though, such a solution with values would be ineffective.
The answer would be: You can’t. Any player (client) has access to everything in their machine.
You cannot detect this either because they can quickly detect what you are using to detect it with.
If that’s not good enough, they can also cancel the kick packet being sent to their client if you attempt to kick them locally.
Although this is partly true, I don’t think it’s impossible, more or less how well you can do it/how experienced a hacker/exploiter is
It is impossible, as long as the client has full access to everything happening on the client-side.
You may deny this, however that is the truth.
Please note: I mentioned that this is impossible on the client, not the server.
And if you do create it on the server, it might have false positives as a lot can cause delay, which will result in innocent players being detected.
Ah, I see. I still think the matter of whether or not it’s “impossible” is about skill and methods though, but, agree to disagree