Disable “bunnyhoping” when player holds down the space button
Basically I want the player to jump only once when holding down the space button.
Make the cooldown 0.5 or something and it should work (i think)
That’s not really what I’m looking for
I suggest taking the value of Humanoid.Jump and once it sets to true then set make a debounce and set the JumpHeight to 0.
Example:
-- Localscript
local LocalPlayer = game.Players.LocalPlayer
local jumpConnection = nil
LocalPlayer.CharacterAdded:Connect(function(Character)
local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
if Humanoid then
if jumpConnection then
jumpConnection:Disconnect()
jumpConnection = nil
end
local inDebounce = false
jumpConnection = Humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
if Humanoid.Jump.Value == true then
if inDebounce == false then
inDebounce = true
Humanoid.JumpHeight = 0
Humanoid.JumpHeight = --Default value here
task.wait(1)
inDebounce = false
end
end
end)
end
end)
I’m not looking for a cooldown since holding down space will still make you jump again after the cooldown is over. I think it has to do something with the default playerscripts. I’ll look into them.
You’re trying to make it so that you have to actually press jump manually, correct?
Yes. That is what I am looking for.
I think there has been a topic that covers this.
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character
local Humanoid
local Landed = 0
local JumpState = true
local Jumping = false
local function SetJumpState(state)
-- Avoid calling Humanoid:SetStateEnabled more than once
if JumpState ~= state then
JumpState = state
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, state)
end
end
local function OnCharacter(character)
Character = character
Humanoid = character:FindFirstChildOfClass("Humanoid")
Humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
if Humanoid.FloorMaterial ~= Enum.Material.Air and Jumping and JumpState then
Landed = tick()
Jumping = false
SetJumpState(false)
end
end)
end
if Player.Character then
OnCharacter(Player.Character)
end
Player.CharacterAdded:Connect(function(character)
Landed = 0
JumpState = true
Jumping = false
OnCharacter(character)
end)
RunService.Heartbeat:Connect(function()
if not JumpState and tick() - Landed > 0.5 then
SetJumpState(true)
end
end)
UserInputService.JumpRequest:Connect(function()
if Humanoid.FloorMaterial ~= Enum.Material.Air then
Jumping = true
end
end)
I haven’t tested this, see if this works, script isn’t made by me
Nope, It doesn’t work. It also makes me unable to move at all for some reason.
It must’ve been Roblox’s updates to their scripts, I’ll try to look for a solution or someone else can, I am not on a computer right now
Try this, I tested this on my computer
local player = game.Players.LocalPlayer
local humanoid = player.CharacterAdded:wait():WaitForChild("Humanoid")
local UserInputService = game:GetService("UserInputService")
local jump = false
UserInputService.JumpRequest:Connect(function()
if humanoid.FloorMaterial == Enum.Material.Air then
jump = true
humanoid.JumpPower = 0
repeat wait() until humanoid.FloorMaterial ~= Enum.Material.Air
jump = false
end
end)
UserInputService.InputBegan:connect(function(inputObject)
if inputObject.KeyCode == Enum.KeyCode.Space then
if jump == false then
humanoid.JumpPower = 50
humanoid.Jump = true
end
end
end)
Script made by socor_lord
local Game = game
local UserInputService = Game:GetService("UserInputService")
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChildOfClass("Humanoid") or Character:WaitForChild("Humanoid")
local function OnInputBegan(InputObject)
if InputObject.KeyCode.Name == "Space" then task.wait() Humanoid:SetStateEnabled("Jumping", false) end
end
local function OnInputEnded(InputObject)
if InputObject.KeyCode.Name == "Space" then task.wait() Humanoid:SetStateEnabled("Jumping", true) end
end
UserInputService.InputBegan:Connect(OnInputBegan)
UserInputService.InputEnded:Connect(OnInputEnded)
In my opinion a cleaner implementation.
If anyone is trying to implement this in their game, it’s outdated and broken a little. I suggest using Forummer’s.