Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.41 KB | None | 0 0
  1.  
  2. local uis = game:GetService("UserInputService")
  3. local suiton = false
  4. local ejected = false
  5. local used = false
  6. local flying=false
  7. local toggle = false
  8. local waiting = false
  9. local waiting2 = false
  10. local hassuit = false
  11. local used2 = false
  12.  
  13.  
  14. script.Done.Changed:Connect(function()
  15. if script.Done.Value == true then
  16. used = true
  17. hassuit = true
  18. suiton = true
  19. script.Suiton.Value = true
  20. end
  21. end)
  22.  
  23. --Eject/PutOnSuit
  24. uis.InputBegan:Connect(function(input,gameProcessedEvent)
  25.  
  26. if input.UserInputType == Enum.UserInputType.Keyboard then
  27. if input.KeyCode == Enum.KeyCode.N and not gameProcessedEvent then
  28. if waiting2 == false then
  29. if suiton == true then
  30. script.Suiton.Value = false
  31. waiting2 = true
  32. script.Parent.Remotes.Eject:FireServer()
  33. ejected = true
  34. suiton = false
  35. wait(6)
  36. waiting2 = false
  37. else if ejected == true then
  38. suiton = true
  39. script.Suiton.Value = true
  40. script.Parent.Remotes.EquipSuit:FireServer()
  41. wait(6)
  42. waiting2 = false
  43. end
  44.  
  45. end
  46. end
  47. end
  48. end
  49. end)
  50.  
  51. --ToggleMask
  52. uis.InputBegan:Connect(function(input,gameProcessedEvent)
  53. if input.UserInputType == Enum.UserInputType.Keyboard then
  54. if input.KeyCode == Enum.KeyCode.M and not gameProcessedEvent then
  55. if suiton == true then
  56. if waiting == false then
  57. if toggle == false then
  58.  
  59. waiting = true
  60. script.Parent.Remotes.ToggleMaskUp:FireServer()
  61. wait(0.2)
  62. toggle = true
  63. print("e")
  64. wait(2)
  65. waiting = false
  66. else
  67. if waiting == false then
  68. waiting = true
  69. print("e2")
  70. script.Parent.Remotes.ToggleMaskDown:FireServer()
  71. wait(0.2)
  72. toggle = false
  73. wait(2)
  74. waiting = false
  75. end
  76. end
  77. end
  78. end
  79. end
  80.  
  81. end
  82. end)
  83. local CoolDownRight = false
  84. --Right Repulsor
  85. uis.InputBegan:Connect(function(input,gameProcessedEvent)
  86. if input.UserInputType == Enum.UserInputType.Keyboard then
  87. if input.KeyCode == Enum.KeyCode.E and not gameProcessedEvent then
  88. if suiton == true then
  89. if CoolDownRight == false then
  90. CoolDownRight = true
  91. local mouse = game.Players.LocalPlayer:GetMouse()
  92. script.Parent.Remotes.RightRepulsorSound:FireServer()
  93. wait(1.2)
  94. script.Parent.Remotes.ChestRepulsorShoot:FireServer(mouse.Hit)
  95. wait(2.8)
  96. CoolDownRight = false
  97. end
  98. end
  99. end
  100. end
  101. end)
  102. local CoolDownLeft = false
  103. --Left Repulsor
  104. uis.InputBegan:Connect(function(input,gameProcessedEvent)
  105. if input.UserInputType == Enum.UserInputType.Keyboard then
  106. if input.KeyCode == Enum.KeyCode.Q and not gameProcessedEvent then
  107. if suiton == true then
  108. if CoolDownLeft == false then
  109. CoolDownLeft = true
  110. local mouse = game.Players.LocalPlayer:GetMouse()
  111. script.Parent.Remotes.LeftRepulsorSound:FireServer()
  112. wait(1.2)
  113. script.Parent.Remotes.LeftRepulsorShoot:FireServer(mouse.Hit)
  114. wait(2.8)
  115. CoolDownLeft = false
  116. end
  117. end
  118. end
  119. end
  120. end)
  121. local CoolDownChest = false
  122. --Chest Repulsor
  123. uis.InputBegan:Connect(function(input,gameProcessedEvent)
  124. if input.UserInputType == Enum.UserInputType.Keyboard then
  125. if input.KeyCode == Enum.KeyCode.R and not gameProcessedEvent then
  126. if suiton == true then
  127. if CoolDownChest == false then
  128. CoolDownChest = true
  129. local mouse = game.Players.LocalPlayer:GetMouse()
  130. script.Parent.Remotes.ChestRepulsorSound:FireServer()
  131. wait(1.481)
  132. script.Parent.Remotes.ChestRepulsorShoot:FireServer(mouse.Hit)
  133. wait(5)
  134. CoolDownChest = false
  135. end
  136. end
  137. end
  138. end
  139. end)
  140.  
  141. --Explode Suit
  142. uis.InputBegan:Connect(function(input,gameProcessedEvent)
  143. if input.UserInputType == Enum.UserInputType.Keyboard then
  144. if input.KeyCode == Enum.KeyCode.P and not gameProcessedEvent then
  145. if suiton == false then
  146. if hassuit == true then
  147. if ejected == true then
  148. if used2 == false then
  149. script.Parent.Remotes.ExplodeSuit:FireServer()
  150. used2 = true
  151. wait(10)
  152. script.Suiton.Value = false
  153. suiton = false
  154. hassuit = false
  155. used = false
  156. waiting = false
  157. waiting2 = false
  158. ejected = false
  159. used2 = false
  160. end
  161. end
  162. end
  163. end
  164. end
  165. end
  166. end)
  167. script.Suiton.Changed:Connect(function()
  168. if suiton == true then
  169. sp=script
  170. plr=game.Players.LocalPlayer
  171. mouse=plr:GetMouse()
  172.  
  173. local speed=5
  174. local topspeed=90
  175.  
  176. local rate=math.huge/math.huge
  177.  
  178. local inertia=1-(speed/topspeed)
  179. local debris=game:GetService("Debris")
  180. local controls={forward=0,backward=0,left=0,right=0}
  181. local momentum=Vector3.new(0,0,0)
  182. local lastmomentum=Vector3.new(0,0,0)
  183. local totalmomentum=0
  184. local tilt=0
  185. local lasttilt=0
  186.  
  187. local anim=script:WaitForChild("IdleANIM_Fly")
  188. local anim2=script:WaitForChild("FowardANIM_Fly")
  189. local hum = plr.Character:WaitForChild("Humanoid")
  190. local Forward = hum:LoadAnimation(anim2)
  191.  
  192. function RemoveFlyStuff()
  193. if plr and plr.Character then
  194. local torso=plr.Character:FindFirstChild("UpperTorso")
  195. if torso~=nil then
  196. for _,v in pairs(torso:GetChildren()) do
  197. if v and (v.Name=="FlightGyro" or v.Name=="FlightVelocity") then
  198. v:remove()
  199. end
  200. end
  201. end
  202. end
  203. if flyanim~=nil then
  204. flyanim:Stop()
  205. end
  206. end
  207.  
  208. function fly() --(de)activate fly mode
  209. flying=not flying
  210. RemoveFlyStuff()
  211. if flying then
  212. if plr and plr.Character then
  213.  
  214. local torso=plr.Character:FindFirstChild("UpperTorso")
  215. local humanoid=plr.Character:FindFirstChild("Humanoid")
  216. if torso and humanoid and humanoid.Health>0 then
  217. momentum=torso.Velocity+(torso.CFrame.lookVector*10)+Vector3.new(0,10,0)
  218. plr.Character.Humanoid.PlatformStand = true
  219. plr.Character.Sounds.StartFly:Play()
  220. plr.Character.Sounds.Inair:Play()
  221. script.Flying.Value = true
  222. script.Parent.Remotes.FlyEffects:FireServer()
  223. local gyro=Instance.new("BodyGyro")
  224. gyro.Name="FlightGyro"
  225. gyro.P=10^4
  226. gyro.maxTorque=Vector3.new(gyro.P,gyro.P,gyro.P)
  227. gyro.cframe=torso.CFrame
  228. gyro.Parent=torso
  229.  
  230. velocity=Instance.new("BodyVelocity")
  231. velocity.Name="FlightVelocity"
  232. velocity.velocity=Vector3.new(0,0,0)
  233. velocity.P=10^3
  234. velocity.maxForce=Vector3.new(1,1,1)*(10^6)
  235. velocity.Parent=torso
  236. flyanim=humanoid:LoadAnimation(anim)
  237. if flyanim~=nil then
  238. flyanim:Stop()
  239. end
  240.  
  241. if flyanim then
  242. flyanim:Play()
  243. end
  244.  
  245. while flying and torso and humanoid and humanoid.Health>0 do
  246. local movement=game.Workspace.CurrentCamera.CoordinateFrame:vectorToWorldSpace(Vector3.new(controls.left+controls.right,math.abs(controls.forward)*.2,controls.forward+controls.backward))*speed
  247.  
  248. momentum=(momentum*inertia)+movement
  249. totalmomentum=momentum.magnitude
  250. if totalmomentum>topspeed then
  251. totalmomentum=topspeed
  252. end
  253.  
  254. local tilt=((momentum*Vector3.new(1,0,1)).unit:Cross(((lastmomentum*Vector3.new(1,0,1)).unit))).y
  255. local tstilt=tostring(tilt)
  256. if tstilt=="-1.#IND" or tstilt=="1.#IND" or tilt==math.huge or tilt==-math.huge or tstilt==tostring(0/0) then
  257. tilt=0
  258. end
  259.  
  260. local abstilt=math.abs(tilt)
  261. if abstilt>.06 or abstilt<.0001 then
  262. if math.abs(lasttilt)>.0001 then
  263. tilt=lasttilt*.9
  264. else
  265. tilt=0
  266. end
  267. else
  268. tilt=(lasttilt*.77)+(tilt*.25) --weighted average
  269. end
  270. lasttilt=tilt
  271.  
  272. if totalmomentum<.5 then
  273. momentum=Vector3.new(0,0,0)
  274. totalmomentum=0
  275. gyro.cframe=game.Workspace.CurrentCamera.CoordinateFrame
  276. else
  277. gyro.cframe=CFrame.new(Vector3.new(0,0,0),momentum)*CFrame.Angles(0,0,tilt*(-20))*CFrame.Angles(math.pi*(-.5)*(totalmomentum/topspeed),0,0)
  278. end
  279. velocity.velocity=momentum
  280. lastmomentum=momentum
  281. wait(rate)
  282. end
  283. RemoveFlyStuff()
  284. flying=false
  285. script.Flying.Value = false
  286. plr.Character.Humanoid.PlatformStand = false
  287. plr.Character.Sounds.Inair:Stop()
  288. script.Parent.Remotes.RemoveFlyEffects:FireServer()
  289. end
  290. end
  291. end
  292. end
  293. script.Flying.Changed:Connect(function()
  294. if script.Flying.Value == false then
  295. RemoveFlyStuff()
  296. flying=false
  297. script.Flying.Value = false
  298. plr.Character.Humanoid.PlatformStand = false
  299. while flying == false do
  300. flyanim:Stop()
  301. Forward:Stop()
  302. script.Parent.Remotes.RemoveFlyEffects:FireServer()
  303. wait()
  304. end
  305. end
  306. end)
  307. local IsFlying = false
  308.  
  309.  
  310.  
  311. while true do
  312. wait()
  313. if plr and plr.Character and plr.Character.Parent==game.Workspace then
  314. break
  315. end
  316. end
  317. mouse.KeyDown:connect(function(Key)
  318.  
  319. if Key == "f" then
  320. mouse.KeyDown:connect(function(key2)
  321. local key=string.byte(key2)
  322. if key==32 then --Space bar
  323.  
  324. IsFlying = not IsFlying
  325. elseif key==string.byte("w") or key==17 then
  326. controls.forward=-1
  327. if flying == true then
  328. script.Parent.Remotes.FlyEffects2:FireServer()
  329. Forward:Play()
  330. end
  331. elseif key==string.byte("a") or key==20 then
  332. controls.left=-1
  333. if flying == true then
  334. script.Parent.Remotes.FlyEffects2:FireServer()
  335. Forward:Play()
  336. end
  337. elseif key==string.byte("s") or key==18 then
  338. controls.backward=1
  339. if flying == true then
  340. script.Parent.Remotes.FlyEffects2:FireServer()
  341. Forward:Play()
  342. end
  343. elseif key==string.byte("d") or key==19 then
  344. controls.right=1
  345. if flying == true then
  346. script.Parent.Remotes.FlyEffects2:FireServer()
  347. Forward:Play()
  348. end
  349. end
  350. end)
  351. mouse.KeyUp:connect(function(key2)
  352. local key=string.byte(key2)
  353. if key==string.byte("w") or key==17 then
  354. controls.forward=0
  355.  
  356. Forward:Stop()
  357. script.Parent.Remotes.FlyEffects:FireServer()
  358. elseif key==string.byte("a") or key==20 then
  359. controls.left=0
  360.  
  361. Forward:Stop()
  362. script.Parent.Remotes.FlyEffects:FireServer()
  363. elseif key==string.byte("s") or key==18 then
  364. controls.backward=0
  365.  
  366. Forward:Stop()
  367. script.Parent.Remotes.FlyEffects:FireServer()
  368. elseif key==string.byte("d") or key==19 then
  369. controls.right=0
  370.  
  371. Forward:Stop()
  372. script.Parent.Remotes.FlyEffects:FireServer()
  373. end
  374. end)
  375. delay(0,function()
  376. fly()
  377. IsFlying = true
  378. end)
  379. end
  380. end)
  381. mouse.KeyDown:connect(function(Key)
  382. if Key == "f" then
  383. if flying then
  384. RemoveFlyStuff()
  385. IsFlying = false
  386. plr.Character.Humanoid.PlatformStand = false
  387. end
  388. end
  389. end)
  390.  
  391. while wait() do
  392. if flying == false then
  393. flyanim:Stop()
  394. end
  395. end
  396. end
  397. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement