Advertisement
RobloxScripTTPoster

(Doors) Sprint Script Execute with Hardcore (Keybind Q)

Dec 17th, 2022 (edited)
1,150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.74 KB | None | 0 0
  1.  
  2. local Parent = game.Players.LocalPlayer.PlayerGui
  3.  
  4. local Sprint = Instance.new("Frame")
  5. local ImageLabel = Instance.new("ImageLabel")
  6. local UICorner = Instance.new("UICorner")
  7. local UIPadding = Instance.new("UIPadding")
  8. local Bar = Instance.new("Frame")
  9. local UICorner_2 = Instance.new("UICorner")
  10. local UIPadding_2 = Instance.new("UIPadding")
  11. local Fill = Instance.new("Frame")
  12. local UICorner_3 = Instance.new("UICorner")
  13.  
  14. --Properties:
  15.  
  16. local StaminaGui = Instance.new("ScreenGui")
  17.  
  18. --Properties:
  19.  
  20. StaminaGui.Name = "StaminaGui"
  21. StaminaGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  22. StaminaGui.Enabled = true
  23. StaminaGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  24.  
  25. Sprint.Name = "Sprint"
  26. Sprint.Parent = StaminaGui
  27. Sprint.AnchorPoint = Vector2.new(0, 1)
  28. Sprint.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  29. Sprint.BackgroundTransparency = 1.000
  30. Sprint.Position = UDim2.new(0.931555569, 0, 0.987179458, 0)
  31. Sprint.Size = UDim2.new(0.0556001104, 0, 0.0756410286, 0)
  32. Sprint.SizeConstraint = Enum.SizeConstraint.RelativeYY
  33. Sprint.ZIndex = 1005
  34.  
  35. ImageLabel.Parent = Sprint
  36. ImageLabel.BackgroundColor3 = Color3.fromRGB(255, 222, 189)
  37. ImageLabel.Size = UDim2.new(1, 0, 1, 0)
  38. ImageLabel.SizeConstraint = Enum.SizeConstraint.RelativeYY
  39. ImageLabel.Visible = false
  40.  
  41. UICorner.CornerRadius = UDim.new(1, 0)
  42. UICorner.Parent = ImageLabel
  43.  
  44. UIPadding.Parent = Sprint
  45. UIPadding.PaddingBottom = UDim.new(0.300000012, -5)
  46. UIPadding.PaddingLeft = UDim.new(0.0199999996, 0)
  47. UIPadding.PaddingRight = UDim.new(0.0500000007, -15)
  48. UIPadding.PaddingTop = UDim.new(0.300000012, -5)
  49.  
  50. Bar.Name = "Bar"
  51. Bar.Parent = Sprint
  52. Bar.AnchorPoint = Vector2.new(0, 0.5)
  53. Bar.BackgroundColor3 = Color3.fromRGB(56, 46, 39)
  54. Bar.BackgroundTransparency = 0.700
  55. Bar.Position = UDim2.new(-2.72600269, 0, 0.499999672, 0)
  56. Bar.Size = UDim2.new(3.60599804, 0, 0.600000083, 0)
  57. Bar.ZIndex = 0
  58.  
  59. UICorner_2.CornerRadius = UDim.new(0.25, 0)
  60. UICorner_2.Parent = Bar
  61.  
  62. UIPadding_2.Parent = Bar
  63. UIPadding_2.PaddingBottom = UDim.new(0, 4)
  64. UIPadding_2.PaddingLeft = UDim.new(0, 4)
  65. UIPadding_2.PaddingRight = UDim.new(0, 4)
  66. UIPadding_2.PaddingTop = UDim.new(0, 4)
  67.  
  68. Fill.Name = "Fill"
  69. Fill.Parent = Bar
  70. Fill.AnchorPoint = Vector2.new(0, 0.5)
  71. Fill.BackgroundColor3 = Color3.fromRGB(213, 185, 158)
  72. Fill.Position = UDim2.new(0, 0, 0.5, 0)
  73. Fill.Size = UDim2.new(1, 0, 1, 0)
  74. Fill.ZIndex = 2
  75.  
  76. UICorner_3.CornerRadius = UDim.new(0.25, 0)
  77. UICorner_3.Parent = Fill
  78.  
  79. local erm = Instance.new("ScreenGui")
  80. local ImageLabel = Instance.new("ImageLabel")
  81. erm.IgnoreGuiInset = true
  82. erm.Name = "erm"
  83. erm.Parent = Parent
  84. erm.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  85.  
  86. ImageLabel.Parent = erm
  87. ImageLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  88. ImageLabel.BackgroundTransparency = 1.000
  89. ImageLabel.Size = UDim2.new(1, 0, 0.998717964, 0)
  90. ImageLabel.Image = "rbxassetid://190596490"
  91. ImageLabel.ImageColor3 = Color3.fromRGB(0, 0, 0)
  92.  
  93. ImageLabel.ImageTransparency = 1
  94.  
  95. -- Services
  96.  
  97. local Players = game:GetService("Players")
  98. local UIS = game:GetService("UserInputService")
  99.  
  100. -- Variables
  101.  
  102. local Plr = Players.LocalPlayer
  103. local Char = Plr.Character or Plr.CharacterAdded:Wait()
  104. local Hum = Char:WaitForChild("Humanoid")
  105.  
  106. local stamina, staminaMax = 100, 100
  107. local sprintTime = 7
  108. local cooldown = false
  109.  
  110. local ModuleScripts = {
  111. MainGame = require(Plr.PlayerGui.MainUI.Initiator.Main_Game),
  112. }
  113.  
  114. -- Setup
  115.  
  116. local nIdx; nIdx = hookmetamethod(game, "__newindex", newcclosure(function(t, k, v)
  117. if k == "WalkSpeed" then
  118. if ModuleScripts.MainGame.chase then
  119. v = ModuleScripts.MainGame.crouching and 15 or 22
  120. elseif ModuleScripts.MainGame.crouching then
  121. v = 8
  122. else
  123. v = isSprinting and 20 or 12
  124. end
  125. end
  126.  
  127. return nIdx(t, k, v)
  128. end))
  129.  
  130. -- Scripts
  131.  
  132. sprintTime = math.max(sprintTime - 1, 1)
  133. local zerostamtween = game.TweenService:Create(ImageLabel,TweenInfo.new(12),{ImageTransparency = 0})
  134. UIS.InputBegan:Connect(function(key, gameProcessed)
  135. if not gameProcessed and key.KeyCode == Enum.KeyCode.Q and not cooldown and not ModuleScripts.MainGame.crouching then
  136. -- Sprinting
  137.  
  138. isSprinting = true
  139. Hum:SetAttribute("SpeedBoost",4)
  140. zerostamtween:Play()
  141. while UIS:IsKeyDown(Enum.KeyCode.Q) and stamina > 0 do
  142. stamina = math.max(stamina - 1, 0)
  143. Fill.Size = UDim2.new(1 / staminaMax * stamina, 1, 1, 0)
  144. task.wait(sprintTime / 100)
  145.  
  146. end
  147.  
  148. -- Reset
  149. zerostamtween:Pause()
  150. isSprinting = false
  151. Hum:SetAttribute("SpeedBoost",0)
  152. game.TweenService:Create(ImageLabel,TweenInfo.new(1),{ImageTransparency = 1}):Play()
  153. Hum.WalkSpeed = 12
  154.  
  155. if stamina == 0 then
  156. -- Cooldown
  157. firesignal(game.ReplicatedStorage.Bricks.Caption.OnClientEvent,"You're exhausted.")
  158. local noStamernaSound = Instance.new("Sound",workspace)
  159. noStamernaSound.SoundId = "rbxassetid://8258601891"
  160. noStamernaSound.Volume = 0.8
  161. noStamernaSound.PlayOnRemove = true
  162. noStamernaSound:Destroy()
  163. cooldown = true
  164. game.TweenService:Create(ImageLabel,TweenInfo.new(0.3),{ImageTransparency = 0}):Play()
  165. wait(0.3)
  166. game.TweenService:Create(ImageLabel,TweenInfo.new(10),{ImageTransparency = 1}):Play()
  167. for i = 1, staminaMax, 1 do
  168. stamina = i
  169. Fill.Size = UDim2.new(1 / staminaMax * i, 1, 1, 0)
  170.  
  171. task.wait(sprintTime / 50)
  172. end
  173.  
  174. cooldown = false
  175. else
  176. -- Refill
  177. cooldown = false
  178. Spawn(function()
  179. --wait(1)
  180. cooldown = false
  181. end)
  182. game.TweenService:Create(ImageLabel,TweenInfo.new(1),{ImageTransparency = 1}):Play()
  183. while not UIS:IsKeyDown(Enum.KeyCode.Q) do
  184. stamina = math.min(stamina + 1, staminaMax)
  185. Fill.Size = UDim2.new(1 / staminaMax * stamina, 1, 1, 0)
  186.  
  187. task.wait(sprintTime / 50)
  188. end
  189. end
  190. end
  191. end)
  192. Hum:SetAttribute("SpeedBoost",0)
  193. Hum.WalkSpeed = 12
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement