so it used to work before but it never works when i try to add a debounce into the script
local bar = script.Parent
local stamina = 100
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local db = false
local isJumping = false
local uis = game:GetService("UserInputService")
humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
if db == false and stamina > 0 then
isJumping = true
db = true
wait(0.5)
db = false
if isJumping then
humanoid.JumpPower = 50
wait()
end
end
end)
while wait() do
if stamina == 0 and isJumping then
isJumping = false
db = true
humanoid.JumpPower = 0
wait(5)
db = false
humanoid.JumpPower = 50
end
if isJumping then
humanoid.JumpPower = 50
stamina -= 20
isJumping = false
wait()
else
stamina += 0.75
wait()
end
stamina = math.clamp(stamina, 0, 100)
bar:TweenSize(UDim2.new((1/100) * stamina, 0, 1 ,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.1)
end
Yeah I’m right here, just went for a bit.
Anyways, you put it inside here:
humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
if db == false and stamina > 0 then
isJumping = true
spawn(function()
db = true
wait(0.5)
db = false
end
if isJumping then
humanoid.JumpPower = 50
wait()
end
end
end)
local bar = script.Parent
local stamina = 100
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local db = false
local isJumping = false
local uis = game:GetService("UserInputService")
spawn(function()
db = true
wait(0.5)
db = false
end)
while wait() do
if stamina == 0 and isJumping then
isJumping = false
db = true
humanoid.JumpPower = 0
wait(5)
db = false
humanoid.JumpPower = 50
end
if isJumping then
humanoid.JumpPower = 50
stamina -= 20
isJumping = false
wait()
else
stamina += 0.75
wait()
end
stamina = math.clamp(stamina, 0, 100)
bar:TweenSize(UDim2.new((1/100) * stamina, 0, 1 ,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.1)
end
humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
if db == false and stamina > 0 then
isJumping = true
spawn(function()
db = true
wait(0.5)
db = false
end
if isJumping then
humanoid.JumpPower = 50
wait()
end
end
end)
local bar = script.Parent
local stamina = 100
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local db = false
local isJumping = false
local uis = game:GetService("UserInputService")
humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
if db == false and stamina > 0 then
isJumping = true
spawn(function()
db = true
wait(0.5)
db = false
end)
if isJumping then
humanoid.JumpPower = 50
wait()
end
end
end)
while wait() do
if stamina == 0 and isJumping then
isJumping = false
db = true
humanoid.JumpPower = 0
wait(5)
db = false
humanoid.JumpPower = 50
end
if isJumping == true then
humanoid.JumpPower = 50
stamina -= 10
isJumping = false
wait()
elseif isJumping == false then
stamina += 0.75
wait()
end
stamina = math.clamp(stamina, 0, 100)
bar:TweenSize(UDim2.new((1/100) * stamina, 0, 1 ,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.1)
end
Jumped the shark a bit soon, oops. Roblox Battle has a similar stamina script if ya wanna check that out. jump_limiter.rbxm (3.5 KB)
OG Reply
Could using Humanoid.Jumping perhaps be a solution? It could be used to detect when the player’s jumping and subtract from the stamina, then in another while loop it increases the stamina. For example,
local Stamina = 100
Humanoid.Jumping:Connect(function(IsJumping)
if IsJumping then
Stamina -= 20
if Stamina < 0 then
-- Disable jumping
end
end
end)
while true do
Stamina += 10
if Stamina > 0 then
-- Renable jumping
end
wait(1)
end
I hope this helped.
EDIT
Open up Roblox studio - you can open up a blank baseplate if ya want. Right click on ServerStorage and select Insert from file. If your browser defaults your downloaded files to your Downloads folder, it’ll be there. Find the file amongst your other files and double click to insert it.
EDIT2
I recommend examining/reverse engineering how Games wrote it. It uses a debounce also, so I think it’d be a worthy read.