RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"make me a sprint bar with shift to sprint"
-- local script local UserInputService = game:GetService("UserInputService") local Players = game:GetService("Players") local player = Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local sprinting = false local sprintBar = player.PlayerGui.ScreenGui.SprintBar local sprintValue = sprintBar.SprintValue local function updateSprintBar(value) sprintValue.Size = UDim2.new(value, 0, 1, 0) end local function toggleSprint() if sprinting then sprinting = false character.Humanoid.WalkSpeed = 16 while not sprinting and sprintValue.Size.X.Scale < 1 do updateSprintBar(sprintValue.Size.X.Scale + 0.01) wait(0.03) end else sprinting = true character.Humanoid.WalkSpeed = 50 while sprinting and sprintValue.Size.X.Scale > 0 do updateSprintBar(sprintValue.Size.X.Scale - 0.01) wait(0.03) end if sprintValue.Size.X.Scale <= 0 then sprinting = false character.Humanoid.WalkSpeed = 16 end end end UserInputService.InputBegan:Connect(function(input, gameProcessedEvent) if input.KeyCode == Enum.KeyCode.LeftShift and not gameProcessedEvent then toggleSprint() end end) UserInputService.InputEnded:Connect(function(input, gameProcessedEvent) if input.KeyCode == Enum.KeyCode.LeftShift and not gameProcessedEvent then toggleSprint() end end)