How to make a Shift to Sprint system in ROBLOX studio (2024)

Поділитися
Вставка
  • Опубліковано 7 кві 2024
  • in this video, I will be teaching you on how to make a shift to sprint script in ROBLOX studio
    script:
    local UserInputService = game:GetService("UserInputService")
    local RunService = game:GetService("RunService")
    local player = game.Players.LocalPlayer
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoid = character:WaitForChild("Humanoid")
    local isRunning = false
    local canRun = true
    local function startRunning()
    if canRun then
    isRunning = true
    humanoid.WalkSpeed = 30
    end
    end
    local function stopRunning()
    isRunning = false
    humanoid.WalkSpeed = 16
    end
    local function handleRun(input)
    if input.KeyCode == Enum.KeyCode.LeftShift then
    if input.UserInputState == Enum.UserInputState.Begin then
    startRunning()
    elseif input.UserInputState == Enum.UserInputState.End then
    stopRunning()
    end
    end
    end
    UserInputService.InputBegan:Connect(handleRun)
    UserInputService.InputEnded:Connect(handleRun)
    while RunService.RenderStepped:Wait() do
    if isRunning then
    wait(10)
    stopRunning()
    canRun = false
    wait(4)
    canRun = true
    end
    end
    how to copy text press ctrl + c / command + c
    how to paste it: ctrl + v / command + v
  • Ігри

КОМЕНТАРІ • 4

  • @nanimatesyt5
    @nanimatesyt5 Місяць тому

    Oh my god thank you you dont know how many video guides I have watch just for it to now work this one works thank you good video

  • @eggiobeggo
    @eggiobeggo Місяць тому

    the script only works one time for me. if i die once, the sprint script doesnt work. do you know how to fix this?

    • @BrookDude
      @BrookDude  Місяць тому

      local UserInputService = game:GetService("UserInputService")
      local RunService = game:GetService("RunService")
      local player = game.Players.LocalPlayer
      local character = player.Character or player.CharacterAdded:Wait()
      local humanoid = character:WaitForChild("Humanoid")
      local isRunning = false
      local canRun = true
      local function startRunning()
      if canRun then
      isRunning = true
      humanoid.WalkSpeed = 30
      end
      end
      local function stopRunning()
      isRunning = false
      humanoid.WalkSpeed = 16
      end
      local function handleRun(input)
      if input.KeyCode == Enum.KeyCode.LeftShift then
      if input.UserInputState == Enum.UserInputState.Begin then
      startRunning()
      elseif input.UserInputState == Enum.UserInputState.End then
      stopRunning()
      end
      end
      end
      local function setupCharacter(character)
      humanoid = character:WaitForChild("Humanoid")
      UserInputService.InputBegan:Connect(handleRun)
      UserInputService.InputEnded:Connect(handleRun)
      isRunning = false
      canRun = true
      end
      setupCharacter(character)
      player.CharacterAdded:Connect(function(newCharacter)
      setupCharacter(newCharacter)
      end)
      RunService.RenderStepped:Connect(function()
      if isRunning then
      wait(10)
      stopRunning()
      canRun = false
      wait(4)
      canRun = true
      end
      end)
      try this