I made a sprinting script for my game and... there's energy and I want the script to stop the player from running if the energy either ='s 0 or the shift key is up my current system the energy still goes down even if the key triggering that part of the script isn't down
Here's my script :
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local empty = false
local stamina = Instance.new("NumberValue", player);
stamina.Value = 100
Mouse.KeyUp:connect(function(shiftUp)
if shiftUp:byte() == 48 then
player.Character.Humanoid.WalkSpeed = 16
end
end)
Mouse.KeyDown:connect(function(shiftDown)
if shiftDown:byte() == 48 then
player.Character.Humanoid.WalkSpeed = 45
while wait(0.1) do
stamina.Value = stamina.Value -1
end
end
end)

2 comments
Oh okay I tried that but I did while sprinting == true do like it was a debounce
while sprinting dois equivalent towhile sprinting == true do.