Advertisement
Drvays

Shift to Sprint with mobile button

Oct 9th, 2022
135,653
6
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 6 0
  1. --[[ Made by coolcapidog
  2. Channel ->> https://www.youtube.com/c/coolcapidog
  3. You can change the settings but you shouldn't change anything except settings.
  4. ]]
  5.  
  6. local NormalWalkSpeed = 16
  7. local SprintSpeed = 25
  8. local CameraEffect = true
  9.  
  10. local cas = game:GetService("ContextActionService")
  11. local Leftc = Enum.KeyCode.LeftControl
  12. local RightC = Enum.KeyCode.RightControl
  13. local player = game:GetService("Players").LocalPlayer
  14. local char = player.Character or player.CharacterAdded:Wait()
  15. local Humanoid = char:WaitForChild("Humanoid")
  16.  
  17. local Camera = game.Workspace.CurrentCamera
  18. local TweenService = game:GetService("TweenService")
  19. local UIS = game:GetService("UserInputService")
  20.  
  21. UIS.InputBegan:Connect(function(key, gameProcessed)
  22. if gameProcessed then return end
  23. if key.KeyCode == Enum.KeyCode.LeftShift then
  24. if CameraEffect == true then
  25. TweenService:Create(Camera, TweenInfo.new(0.5), {FieldOfView = 90}):Play()
  26. end
  27. Humanoid.WalkSpeed = SprintSpeed
  28. end
  29. end)
  30.  
  31. UIS.InputEnded:Connect(function(key, gameProcessed)
  32. if gameProcessed then return end
  33. if key.KeyCode == Enum.KeyCode.LeftShift then
  34. if CameraEffect == true then
  35. TweenService:Create(Camera, TweenInfo.new(0.5), {FieldOfView = 70}):Play()
  36. end
  37. Humanoid.WalkSpeed = NormalWalkSpeed
  38. end
  39. end)
  40.  
  41. --------------------------------------------------- Mobile Button
  42.  
  43. local function handleContext(name, state, input)
  44. if state == Enum.UserInputState.Begin then
  45. if CameraEffect == true then
  46. TweenService:Create(Camera, TweenInfo.new(0.5), {FieldOfView = 90}):Play()
  47. end
  48. Humanoid.WalkSpeed = SprintSpeed
  49. else
  50. if CameraEffect == true then
  51. TweenService:Create(Camera, TweenInfo.new(0.5), {FieldOfView = 70}):Play()
  52. end
  53. Humanoid.WalkSpeed = NormalWalkSpeed
  54. end
  55. end
  56.  
  57. cas:BindAction("Sprint", handleContext, true, Leftc, RightC)
  58. cas:SetPosition("Sprint", UDim2.new(.2, 0, .5, 0))
  59. cas:SetTitle("Sprint", "Sprint")
  60. cas:GetButton("Sprint").Size = UDim2.new(.3, 0, .3, 0)
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement