1992x

not mine

Dec 29th, 2020
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. -- Author: 0xEB (maxbd, maxbd07, maxbd123)
  2. -- Special thanks to InvalidCo_de (GrundyCone) for informing me of "UserInputService.MouseBehavior" and "Enum.MouseBehavior.LockCenter."
  3. local options = {
  4. WalkSpeed = 100,
  5. HotKey = Enum.KeyCode.E
  6. }
  7. local UserInputService = game:GetService("UserInputService")
  8. local PAYER = game:GetService("Players").LocalPlayer
  9. local HUMANOID = PLAYER.Character:FindFirstChild("Humanoid") or PLAYER.Character:FindFirstChildOfClass("Humanoid")
  10. local ROOT = PLAYER.Character:FindFirstChild("HumanoidRootPart") or PLAYER.Character.PrimaryPart
  11. local vA = (options.WalkSpeed - HUMANOID.WalkSpeed) / 32
  12. local vB, vC, vD = false, false, {}
  13. HUMANOID.Running:Connect(function(pA)
  14. vB = (pA > 0) and true or false
  15. end)
  16. local function GetDirectionVector(pA, pB)
  17. local vA = Vector3.new(0, 0, 0)
  18. vA = vA + ((pB[1] == true) and pA.CFrame.LookVector or Vector3.new(0, 0, 0))
  19. vA = vA + ((pB[2] == true) and pA.CFrame:VectorToWorldSpace(Vector3.new(-1, 0, 0)) or Vector3.new(0, 0, 0))
  20. vA = vA + ((pB[3] == true) and pA.CFrame:VectorToWorldSpace(Vector3.new(0, 0, 1)) or Vector3.new(0, 0, 0))
  21. vA = vA + ((pB[4] == true) and pA.CFrame:VectorToWorldSpace(Vector3.new(1, 0, 0)) or Vector3.new(0, 0, 0))
  22.  
  23. return vA
  24. end
  25. UserInputService.InputBegan:Connect(function(pA, pB)
  26. if pA.UserInputType == Enum.UserInputType.Keyboard and pB == false then
  27. if pA.KeyCode == options.HotKey then
  28. vC, vD = (vC == false) and true or false, {true, false, false, false}
  29.  
  30. while vC == true and wait() do
  31. if UserInputService.MouseBehavior ~= Enum.MouseBehavior.LockCenter then
  32. ROOT.CFrame = ROOT.CFrame + ROOT.CFrame.LookVector * vA
  33. else
  34. ROOT.CFrame = ROOT.CFrame + GetDirectionVector(ROOT, vD) * vA
  35. end
  36. end
  37. end
  38.  
  39. if vC == true then
  40. if pA.KeyCode == Enum.KeyCode.W then vD[1], vD[3] = true, false end
  41. if pA.KeyCode == Enum.KeyCode.A then vD[2], vD[4] = true, false end
  42. if pA.KeyCode == Enum.KeyCode.S then vD[3], vD[1] = true, false end
  43. if pA.KeyCode == Enum.KeyCode.D then vD[4], vD[2] = true, false end
  44. end
  45. end
  46. end)
  47. UserInputService.InputEnded:Connect(function(pA, pB)
  48. if pA.UserInputType == Enum.UserInputType.Keyboard and pB == false and vC == true then
  49. if pA.KeyCode == Enum.KeyCode.W then vD[1] = false end
  50. if pA.KeyCode == Enum.KeyCode.A then vD[2] = false end
  51. if pA.KeyCode == Enum.KeyCode.S then vD[3] = false end
  52. if pA.KeyCode == Enum.KeyCode.D then vD[4] = false end
  53. end
  54. end)
Advertisement
Add Comment
Please, Sign In to add comment