Jump cooldown doesn't work?

This whole jump cooldown thing isn’t working, the prints work but the jumppower just doesn’t change

localscript (in startercharacterscripts)

i’ve tried 2 methods:

local UIS = game:GetService("UserInputService")

local Char = script.Parent
local Humanoid = Char:WaitForChild("Humanoid")

local Jumped = false

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Space and not Jumped then
		print("work")
		Jumped = true
		
		Humanoid.JumpPower = 0
		print("jump0")
		task.wait(1)
		Humanoid.JumpPower = 50
		Jumped = false
	end
end)

and

local Char = script.Parent
local Humanoid = Char:WaitForChild("Humanoid")

local Jumping = false

Humanoid.Jumping:Connect(function()
    if Jumping then return end
    
    Jumping = true
    Humanoid.JumpPower = 0
    
    task.wait(1)
    
    Humanoid.JumpPower = 50
    Jumping = false
end)
2 Likes

Gotta change it server side I think

1 Like
local inCooldown = false
local cooldown = 1
local humanoid = script.Parent:WaitForChild("Humanoid")

humanoid.StateChanged:Connect(function(old,new)
	if new == Enum.HumanoidStateType.Jumping then
		humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping,false)
		wait(cooldown )
		humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping,true)
	end
end)

Place in StarterCharacterScripts

2 Likes

image

why did MY method not work???

In starterplayer there is a property and by default for some reason it doesnt take jump power so you gotta tick off “CharacterUseJumpPower”
image

1 Like

Use Humanoid.JumpHeight = 0 and Humanoid.JumpHeight = 7.2 instead.

2 Likes

As @Daniel1154 mentioned, you would have needed to enable StarterPlayer.CharacterUseJumpPower for each player’s Character who spawns into the game to utilize the value set for Humanoid.JumpPower when trying to jump.

If it’s not enabled, then you would need to update Humanoid.JumpHeight, as @Forummer pointed out, since the Humanoid will refer to that property by default instead of JumpPower.


On a side note, the Roblox Creator Documentation site advises against updating either Humanoid.JumpPower or Humanoid.JumpHeight to disable the Character’s ability to jump. It recommends using Humanoid:SetStateEnabled() to achieve that instead, which is what @MrOnlyKemal used in the post you marked as the solution.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.