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