Advertisement
ERROR_CODE

RunButton

Dec 2nd, 2023 (edited)
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.09 KB | None | 0 0
  1. --[[local ScreenGui = Instance.new("ScreenGui")
  2. local RunButton = Instance.new("ImageButton")
  3. local Stamina = Instance.new("Frame")
  4. local RunButtonUICorner = Instance.new("UICorner")
  5. local StaminaUICorner = Instance.new("UICorner")
  6. local UserInputService = game:GetService("UserInputService")
  7. local stamina = 20
  8. local running = false
  9. stamina = math.clamp(stamina,0,28)
  10. ScreenGui.Parent = game.CoreGui
  11. Stamina.Name = "Stamina"
  12. Stamina.Parent = ScreenGui
  13. Stamina.Position = UDim2.new(0, 0, 0.95, 0)
  14. Stamina.Size = UDim2.new(stamina/20,0,0.02,0)
  15. Stamina.BackgroundColor3 = Color3.new(50, 222, 0)
  16. Stamina.BorderSizePixel = 0
  17. Stamina.BackgroundTransparency = 0.5
  18. RunButton.Name = "RunButton"
  19. RunButton.Parent = ScreenGui
  20. RunButton.Position = UDim2.new(0.8, 0, 0.4, 0)
  21. RunButton.Size = UDim2.new(0, 50, 0, 50)
  22. RunButton.BackgroundColor3 = Color3.new(255, 255, 255)
  23. RunButton.Image = "rbxassetid://15527612616"
  24. RunButton.MouseButton1Down:connect(function()
  25. if RunButton.Image == "rbxassetid://15527612616" then
  26. RunButton.Image = "rbxassetid://15527570851"
  27. running = true
  28.         game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 20
  29.         while stamina > 0 and running do
  30.             stamina = stamina - 0.05
  31.             Stamina:TweenSize(UDim2.new(stamina/ 20,0,0.02,0), "Out","Linear",0)
  32.             wait()
  33.             if stamina < 1 then
  34.                 game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 10
  35.             end
  36.         end
  37. else
  38. if RunButton.Image == "rbxassetid://15527570851" then
  39. RunButton.Image = "rbxassetid://15527612616"
  40. running = false
  41.         game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 10
  42.         while stamina < 20 and not running do
  43.             stamina = stamina + 0.05
  44.             Stamina:TweenSize(UDim2.new(stamina/20,0,0.02,0), "Out","Linear",0)
  45.             wait()
  46.             if stamina < 1 then
  47.                 game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 10
  48.             end
  49.         end
  50. end
  51. end
  52. end)
  53. RunButtonUICorner.Name = "RunButtonUICorner"
  54. RunButtonUICorner.Parent = RunButton
  55. RunButtonUICorner.CornerRadius = UDim.new(1, 1)
  56. StaminaUICorner.Name = "StaminaUICorner"
  57. StaminaUICorner.Parent = Stamina]]--
  58. --[[UserInputService.InputBegan:Connect(function(input)
  59. if input.KeyCode == Enum.KeyCode.LeftShift then
  60. running = true
  61.         game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 20
  62.         while stamina > 0 and running do
  63.             stamina = stamina - 0.05
  64.             Stamina:TweenSize(UDim2.new(stamina/ 20,0,0.02,0), "Out","Linear",0)
  65.             wait()
  66.             if stamina < 1 then
  67.                 game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 10
  68.             end
  69.         end
  70. else
  71. running = false
  72.         game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 10
  73.         while stamina < 20 and not running do
  74.             stamina = stamina + 0.05
  75.             Stamina:TweenSize(UDim2.new(stamina/20,0,0.02,0), "Out","Linear",0)
  76.             wait()
  77.             if stamina < 1 then
  78.                 game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 10
  79.             end
  80.         end
  81. end
  82. end)]]--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement