Advertisement
DARKMODZ

function

Oct 21st, 2023
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.57 KB | None | 0 0
  1. D4.Flying = function(Toggle, Speed)
  2. getgenv().Toggle1 = Toggle
  3. if Toggle then
  4. print("Yes")
  5. local Max = 0
  6. local LP = Players.LocalPlayer
  7. local Mouse = LP:GetMouse()
  8. Max = Max + 1
  9. if Toggle then
  10. local T = LP.Character:FindFirstChild("UpperTorso",true) or LP.Character:FindFirstChild("HumanoidRootPart",true)
  11. local S = {
  12. F = 0,
  13. B = 0,
  14. L = 0,
  15. R = 0
  16. }
  17. local S2 = {
  18. F = 0,
  19. B = 0,
  20. L = 0,
  21. R = 0
  22. }
  23. local SPEED = 5
  24. local function FLY()
  25. local BodyGyro = Instance.new("BodyGyro", T)
  26. local BodyVelocity = Instance.new("BodyVelocity", T)
  27. BodyGyro.P = 9e4
  28. BodyGyro.maxTorque = Vector3.new(9e9, 9e9, 9e9)
  29. BodyGyro.cframe = T.CFrame
  30. BodyVelocity.velocity = Vector3.new(0, 0, 0)
  31. BodyVelocity.maxForce = Vector3.new(9e9, 9e9, 9e9)
  32. spawn(function()
  33. repeat wait()
  34. LP.Character.Humanoid.PlatformStand = true
  35. if S.L + S.R ~= 0 or S.F + S.B ~= 0 then
  36. SPEED = Speed
  37. elseif not (S.L + S.R ~= 0 or S.F + S.B ~= 0) and SPEED ~= 0 then
  38. SPEED = 0
  39. end
  40. if (S.L + S.R) ~= 0 or (S.F + S.B) ~= 0 then
  41. BodyVelocity.velocity =
  42. ((Workspace.CurrentCamera.CoordinateFrame.lookVector * (S.F + S.B)) +
  43. ((Workspace.CurrentCamera.CoordinateFrame *
  44. CFrame.new(S.L + S.R, (S.F + S.B) * 0.2, 0).p) -
  45. Workspace.CurrentCamera.CoordinateFrame.p)) *
  46. SPEED
  47. S2 = {
  48. F = S.F,
  49. B = S.B,
  50. L = S.L,
  51. R = S.R
  52. }
  53. elseif (S.L + S.R) == 0 and (S.F + S.B) == 0 and SPEED ~= 0 then
  54. BodyVelocity.velocity =
  55. ((Workspace.CurrentCamera.CoordinateFrame.lookVector * (S2.F + S2.B)) +
  56. ((Workspace.CurrentCamera.CoordinateFrame *
  57. CFrame.new(S2.L + S2.R, (S2.F + S2.B) * 0.2, 0).p) -
  58. Workspace.CurrentCamera.CoordinateFrame.p)) *
  59. SPEED
  60. else
  61. BodyVelocity.velocity = Vector3.new(0, 0.1, 0)
  62. end
  63. BodyGyro.cframe = Workspace.CurrentCamera.CoordinateFrame
  64. until not Toggle or not Toggle1
  65. S = {
  66. F = 0,
  67. B = 0,
  68. L = 0,
  69. R = 0
  70. }
  71. S2 = {
  72. F = 0,
  73. B = 0,
  74. L = 0,
  75. R = 0
  76. }
  77. SPEED = 0
  78. BodyGyro:destroy()
  79. BodyVelocity:destroy()
  80. LP.Character.Humanoid.PlatformStand = false
  81. end
  82. )
  83. end
  84. Mouse.KeyDown:connect(
  85. function(k)
  86. if k:lower() == "w" then
  87. S.F = 1
  88. elseif k:lower() == "s" then
  89. S.B = -1
  90. elseif k:lower() == "a" then
  91. S.L = -1
  92. elseif k:lower() == "d" then
  93. S.R = 1
  94. end
  95. end
  96. )
  97. Mouse.KeyUp:connect(
  98. function(k)
  99. if k:lower() == "w" then
  100. S.F = 0
  101. elseif k:lower() == "s" then
  102. S.B = 0
  103. elseif k:lower() == "a" then
  104. S.L = 0
  105. elseif k:lower() == "d" then
  106. S.R = 0
  107. end
  108. end
  109. )
  110. FLY()
  111. if Max == 2 then
  112. Max = 0
  113. end
  114. end
  115. end
  116. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement