Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game:GetService("Players").LocalPlayer
- local UserInputService = game:GetService("UserInputService")
- local Blur = Instance.new("BlurEffect")
- local MaxSprint = 100
- local SprintDepletion = 0.5
- local SprintRegeneration = 0.1
- local Sprinting = false
- local sprintValue = MaxSprint
- Blur.Parent = game:GetService("Lighting")
- local ScreenGui = Instance.new("ScreenGui")
- ScreenGui.Parent = player.PlayerGui
- local SprintBar = Instance.new("Frame")
- SprintBar.Parent = ScreenGui
- SprintBar.Size = UDim2.new(0.8, 0, 0, 10)
- SprintBar.Position = UDim2.new(0.1, 0, 0.9, 0)
- SprintBar.BackgroundColor3 = Color3.fromRGB(0, 100, 0)
- SprintBar.BorderColor3 = Color3.fromRGB(0, 0, 0)
- SprintBar.BorderSizePixel = 1
- SprintBar.ZIndex = 10
- local SprintBarOverlay = Instance.new("Frame")
- SprintBarOverlay.Parent = SprintBar
- SprintBarOverlay.Size = UDim2.new(1, 0, 1, 0)
- SprintBarOverlay.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
- SprintBarOverlay.BorderSizePixel = 0
- SprintBarOverlay.ZIndex = 9
- local function UpdateSprintBar()
- local sprintPercentage = sprintValue / MaxSprint
- local depletedColor = Color3.fromRGB(200, 255, 200)
- local normalColor = Color3.fromRGB(0, 255, 0)
- SprintBarOverlay.Size = UDim2.new(sprintPercentage, 0, 1, 0)
- SprintBarOverlay.BackgroundColor3 = depletedColor:lerp(normalColor, sprintPercentage)
- if sprintPercentage == 0 then
- Blur.Enabled = true
- player.Character.Humanoid.WalkSpeed = 16
- else
- Blur.Enabled = false
- end
- end
- local function StartSprinting()
- if sprintValue > 0 and not Sprinting then
- Sprinting = true
- player.Character.Humanoid.WalkSpeed = 32
- UpdateSprintBar()
- end
- end
- local function StopSprinting()
- if Sprinting then
- Sprinting = false
- player.Character.Humanoid.WalkSpeed = 16
- UpdateSprintBar()
- end
- end
- UserInputService.InputBegan:Connect(function(input, gameProcessed)
- if not gameProcessed and input.KeyCode == Enum.KeyCode.LeftShift then
- StartSprinting()
- end
- end)
- UserInputService.InputEnded:Connect(function(input, gameProcessed)
- if not gameProcessed and input.KeyCode == Enum.KeyCode.LeftShift then
- StopSprinting()
- end
- end)
- while true do
- wait(0.1)
- if Sprinting then
- sprintValue = math.max(0, sprintValue - SprintDepletion)
- UpdateSprintBar()
- if sprintValue <= 0 then
- StopSprinting()
- end
- elseif sprintValue < MaxSprint then
- sprintValue = math.min(MaxSprint, sprintValue + SprintRegeneration)
- UpdateSprintBar()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement