Advertisement
mathljn

Untitled

May 15th, 2024
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. -- Press X to fly
  2.  
  3. local plr = game.Players.LocalPlayer
  4. local mouse = plr:GetMouse()
  5.  
  6. local localplayer = plr
  7.  
  8. if workspace:FindFirstChild("Core") then
  9. workspace.Core:Destroy()
  10. end
  11.  
  12. local Core = Instance.new("Part")
  13. Core.Name = "Core"
  14. Core.Size = Vector3.new(0.05, 0.05, 0.05)
  15.  
  16. spawn(function()
  17. Core.Parent = workspace
  18. local Weld = Instance.new("Weld", Core)
  19. Weld.Part0 = Core
  20. Weld.Part1 = localplayer.Character.LowerTorso
  21. Weld.C0 = CFrame.new(0, 0, 0)
  22. end)
  23.  
  24. workspace:WaitForChild("Core")
  25.  
  26. local torso = workspace.Core
  27. local flying = true
  28. local speed = 10
  29. local keys = {a = false, d = false, w = false, s = false}
  30.  
  31. local function start()
  32. local pos = Instance.new("BodyPosition", torso)
  33. local gyro = Instance.new("BodyGyro", torso)
  34. pos.Name = "EPIXPOS"
  35. pos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  36. pos.Position = torso.Position
  37. gyro.MaxTorque = Vector3.new(9e9, 9e9, 9e9)
  38. gyro.CFrame = torso.CFrame
  39. repeat
  40. wait()
  41. localplayer.Character.Humanoid.PlatformStand = true
  42. local new = gyro.CFrame - gyro.CFrame.p + pos.Position
  43. if not keys.w and not keys.s and not keys.a and not keys.d then
  44. speed = 5
  45. end
  46. if keys.w then
  47. new = new + workspace.CurrentCamera.CoordinateFrame.LookVector * speed
  48. speed = speed + 0
  49. end
  50. if keys.s then
  51. new = new - workspace.CurrentCamera.CoordinateFrame.LookVector * speed
  52. speed = speed + 0
  53. end
  54. if keys.d then
  55. new = new * CFrame.new(speed, 0, 0)
  56. speed = speed + 0
  57. end
  58. if keys.a then
  59. new = new * CFrame.new(-speed, 0, 0)
  60. speed = speed + 0
  61. end
  62. if speed > 10 then
  63. speed = 5
  64. end
  65. pos.Position = new.p
  66. if keys.w then
  67. gyro.CFrame = workspace.CurrentCamera.CoordinateFrame * CFrame.Angles(-math.rad(speed * 0), 0, 0)
  68. elseif keys.s then
  69. gyro.CFrame = workspace.CurrentCamera.CoordinateFrame * CFrame.Angles(math.rad(speed * 0), 0, 0)
  70. else
  71. gyro.CFrame = workspace.CurrentCamera.CoordinateFrame
  72. end
  73. until flying == false
  74. gyro:Destroy()
  75. pos:Destroy()
  76. flying = false
  77. localplayer.Character.Humanoid.PlatformStand = false
  78. speed = 10
  79. end
  80.  
  81. local function onKeyPress(key)
  82. if not torso or not torso.Parent then
  83. flying = false
  84. mouse.KeyDown:Disconnect()
  85. mouse.KeyUp:Disconnect()
  86. return
  87. end
  88. if key == "w" then
  89. keys.w = true
  90. elseif key == "s" then
  91. keys.s = true
  92. elseif key == "a" then
  93. keys.a = true
  94. elseif key == "d" then
  95. keys.d = true
  96. end
  97. end
  98.  
  99. local function onKeyRelease(key)
  100. if key == "w" then
  101. keys.w = false
  102. elseif key == "s" then
  103. keys.s = false
  104. elseif key == "a" then
  105. keys.a = false
  106. elseif key == "d" then
  107. keys.d = false
  108. end
  109. end
  110.  
  111. mouse.KeyDown:Connect(onKeyPress)
  112. mouse.KeyUp:Connect(onKeyRelease)
  113.  
  114. start()
  115.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement