Hey, I was wondering if someone could help me make a JumpCooldown script, I have no idea how to make it and it is pretty essential for the game I am making.
Thanks
Hey, I was wondering if someone could help me make a JumpCooldown script, I have no idea how to make it and it is pretty essential for the game I am making.
Thanks
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local stamina = 50 -- how much stamina
local function refill()
local isJumping = false
spawn(function()
isJumping = char.Humanoid.Jumping:Wait()
end)
wait(3)
while stamina < 100 and not isJumping do -- Add until stamina is full but if the player jumped since beginning iteration, it will cancel.
stamina = stamina + 1
if stamina == 10 then
-- Undo the effect from being banned from jumping due to lack of stamina
char.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
end
print('Refilling, stamina is', stamina)
wait(.1)
end
end
char:WaitForChild("Humanoid").Jumping:Connect(function(starting)
if starting then
print("Jumped")
stamina = stamina - 10
if stamina < 10 then
-- This will only take effect for the NEXT jump so you need to disable jumping a bit earlier
char.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
print("Next jump blocked! Stamina is", stamina)
end
else -- When the player exits jump
print("Jump event exited with stamina", stamina)
refill()
end
end)
Oh!
I wasn’t asking for the full script but tysm.
make sure to mark things as the solution if it is