Advertisement
Hr_Studios

The Stamina bar script!

Apr 22nd, 2022
5,865
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local character = player.Character
  3.  
  4. local UserInputService = game:GetService("UserInputService")
  5.  
  6. local stamina = 100
  7. local running = false
  8.  
  9. stamina = math.clamp(stamina,0,100)
  10.  
  11. UserInputService.InputBegan:Connect(function(input)
  12. if input.KeyCode == Enum.KeyCode.LeftShift then
  13. running = true
  14. character.Humanoid.WalkSpeed = 32
  15. while stamina > 0 and running do
  16. stamina = stamina - 1
  17. script.Parent:TweenSize(UDim2.new(stamina / 100,0,1,0), "Out","Linear", 0)
  18. wait()
  19. if stamina == 0 then
  20. character.Humanoid.WalkSpeed = 16
  21. end
  22. end
  23. end
  24. end)
  25.  
  26. UserInputService.InputEnded:Connect(function(input)
  27. if input.KeyCode == Enum.KeyCode.LeftShift then
  28. running = false
  29. character.Humanoid.WalkSpeed = 16
  30. while stamina < 100 and not running do
  31. stamina = stamina + 1
  32. script.Parent:TweenSize(UDim2.new(stamina / 100,0,1,0), "Out","Linear", 0)
  33. wait()
  34. if stamina == 0 then
  35. character.Humanoid.WalkSpeed = 16
  36. end
  37. end
  38. end
  39. end)
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement