This is the exploit script that I am trying to patch:
local justSpawned = true
local lastJump = 0
local minJumpDelay = 2
InfiniteJumpEnabled = false
game:GetService("UserInputService").JumpRequest:Connect(function()
if InfiniteJumpEnabled then
game:GetService"Players".LocalPlayer.Character:FindFirstChildOfClass'Humanoid':ChangeState("Jumping")
end
end)
This is my server sided script to patch it. It detects when a player jumps, and kicks them if they jump again within 0.5 seconds later.
local LastJumps = {}
local Connections = {}
local MinJumpDelay = 0.5
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
local Id = Player.UserId
Connections[Player.UserId] = Player.CharacterAdded:Connect(function(Char)
LastJumps[Id] = 0
local Humanoid = Char:WaitForChild("Humanoid", 2)
if Humanoid then
local StateConnection
local DiedConnection
local function OnStateChange(State)
if State == Enum.HumanoidStateType.Jumping then
print(tick() - LastJumps[Id])
if LastJumps[Id] and ((tick() - LastJumps[Id]) < MinJumpDelay) then
Player:Kick("InfJump")
StateConnection:Disconnect()
DiedConnection:Disconnect()
end
LastJumps[Id] = tick()
end
if State == Enum.HumanoidStateType.Landed or State == Enum.HumanoidStateType.Running or State == Enum.HumanoidStateType.RunningNoPhysics then
print("Land/Run")
if LastJumps[Id] then
LastJumps[Id] = tick() - MinJumpDelay
end
end
end
StateConnection = Humanoid.StateChanged:Connect(OnStateChange)
local function OnDied()
StateConnection:Disconnect()
DiedConnection:Disconnect()
end
DiedConnection = Humanoid.Died:Connect(OnDied)
end
end)
end)
Players.PlayerRemoving:Connect(function(Player)
Connections[Player.UserId]:Disconnect()
end)
The issue is that when a player sort of bounces off a rotated part, it detects it as a jump (even if they didn’t click the space bar because I’m using GetState) and they get kicked. To help you imagine this scenario, look at this tree model:
And here’s what I mean by a bounce off:
Does anyone know of anything I could do to stop this behavior, or is this approach to an anti-infinite jump a lost cause?