Dark_EccentricYT

Untitled

Aug 15th, 2017
2,183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.96 KB | None | 0 0
  1.  
  2. repeat wait() until game:IsLoaded() and game:service("Players").LocalPlayer.Character ~= nil;
  3. wait(0.4)
  4. for i, v in pairs(game:service("Players").LocalPlayer.Character:children()) do
  5. if v ~= script then
  6. v:Destroy()
  7. end
  8. end
  9.  
  10. local player = game:service("Players").LocalPlayer
  11. local mouse = player:GetMouse()
  12. local cam = workspace.CurrentCamera
  13. local char = player.Character
  14. local Torsoz = char:findFirstChild("Torso")
  15. local NV = Vector3.new()
  16. local Main
  17. local W,S = false,false
  18. local DoublePress = {nil,0}
  19. script.Parent = char
  20.  
  21. local TrailParts = {}
  22. local Acceleration = 0.08
  23. local Speed = 0
  24. local MinSpeed = 0
  25. local MaxSpeed = 3.2
  26. local DesiredDirection = cam.CoordinateFrame.lookVector
  27. local Direction = DesiredDirection
  28. local Roll = 0
  29. local AllowTrails = true
  30.  
  31. script.Name = "AdvFlight"
  32.  
  33. local P = Instance.new("Part")
  34. P.Anchored = true
  35. P.CanCollide = false
  36. P.Name = "Part"
  37. P.formFactor = "Custom"
  38. P.Size = Vector3.new(0.2,0.2,0.2)
  39. P.Locked = true
  40. P.TopSurface = 10
  41. P.BottomSurface = 10
  42. P.FrontSurface = 10
  43. P.BackSurface = 10
  44. P.LeftSurface = 10
  45. P.RightSurface = 10
  46. P.Material = "Pebble"
  47. P.BrickColor = BrickColor.new("White")
  48.  
  49. local shipp
  50. local shadow
  51. local campart
  52.  
  53. function RAY(pos, dir, startpos, endpos, distleft, collidedlist)
  54. collidedlist = collidedlist or {char}
  55. startpos = startpos or pos
  56. distleft = distleft or dir.unit * dir.magnitude
  57. endpos = endpos or pos + distleft
  58. local ray = Ray.new(pos, distleft)
  59. local hitz,enz = workspace:FindPartOnRayWithIgnoreList(ray, collidedlist)
  60. if hitz ~= nil then
  61. if hitz.CanCollide == false then
  62. table.insert(collidedlist, hitz)
  63. local newpos = enz
  64. local newdistleft = distleft - (dir.unit * (pos - newpos).magnitude)
  65. if newdistleft ~= NV then
  66. return RAY(newpos-(dir*0.01), dir, startpos, endpos, newdistleft+(dir*0.01), collidedlist)
  67. end
  68. end
  69. end
  70. return hitz, enz, ray
  71. end
  72.  
  73. function FindSurface(part, position)
  74. local obj = part.CFrame:pointToObjectSpace(position)
  75. local siz = part.Size/2
  76. for i,v in pairs(Enum.NormalId:GetEnumItems()) do
  77. local vec = Vector3.FromNormalId(v)
  78. local wvec = part.CFrame:vectorToWorldSpace(vec)
  79. local vz = (obj)/(siz*vec)
  80. if (math.abs(vz.X-1) < 0.01 or math.abs(vz.Y-1) < 0.01 or math.abs(vz.Z-1) < 0.01) then
  81. return wvec,vec
  82. end
  83. end
  84. if part.className == "WedgePart" then
  85. return part.CFrame:vectorToWorldSpace(Vector3.new(0,0.707,-0.707)), Vector3.new(0,0.707,-0.707)
  86. end
  87. end
  88.  
  89. function HSV(H,S,V)
  90. H = H % 360
  91. local C = V * S
  92. local H2 = H/60
  93. local X = C * (1 - math.abs((H2 %2) -1))
  94. local color = Color3.new(0,0,0)
  95. if H2 <= 0 then
  96. color = Color3.new(C,0,0)
  97. elseif 0 <= H2 and H2 <= 1 then
  98. color = Color3.new(C,X,0)
  99. elseif 1 <= H2 and H2 <= 2 then
  100. color = Color3.new(X,C,0)
  101. elseif 2 <= H2 and H2 <= 3 then
  102. color = Color3.new(0,C,X)
  103. elseif 3 <= H2 and H2 <= 4 then
  104. color = Color3.new(0,X,C)
  105. elseif 4 <= H2 and H2 <= 5 then
  106. color = Color3.new(X,0,C)
  107. elseif 5 <= H2 and H2 <= 6 then
  108. color = Color3.new(C,0,X)
  109. end
  110. local m = V - C
  111. return Color3.new(color.r + m, color.g + m, color.b + m)
  112. end
  113.  
  114. function Build(shiptype)
  115. AllowTrails = true
  116. for i, v in pairs(char:children()) do
  117. if v.className == "Model" and v.Name == "Ship" then
  118. v:remove()
  119. end
  120. end
  121. for i, v in pairs(TrailParts) do
  122. for _,V in pairs(v[3]) do
  123. V:Destroy()
  124. end
  125. end
  126. local mdl = Instance.new("Model", char)
  127. mdl.Name = "Ship"
  128.  
  129. ------------------------ Speeder Ship Type -----------------------------
  130. if shiptype == "Speeder" then
  131.  
  132. shipp = P:Clone()
  133. shipp.Parent = mdl
  134. shipp.Size = Vector3.new(1,1,2.2)
  135. local shipwing1 = P:Clone()
  136. shipwing1.Parent = mdl
  137. shipwing1.Size = Vector3.new(0.6,1.2,2)
  138. local mesh = Instance.new("SpecialMesh", shipwing1)
  139. mesh.MeshType = "Wedge"
  140. local shipwing2 = shipwing1:Clone()
  141. shipwing2.Parent = mdl
  142. campart = P:Clone()
  143. campart.Transparency = 1
  144. local shipwing21 = P:Clone()
  145. shipwing21.Parent = mdl
  146. shipwing21.Size = Vector3.new(0.32,1.1,2.6)
  147. local mesh = Instance.new("SpecialMesh", shipwing21)
  148. mesh.MeshType = "Wedge"
  149. local shipwing22 = shipwing21:Clone()
  150. shipwing22.Parent = mdl
  151. campart = P:Clone()
  152. campart.Transparency = 1
  153.  
  154. local shipwi = P:Clone()
  155. shipwi.Parent = mdl
  156. shipwi.Size = Vector3.new(1,1,1.2)
  157. local mesh = Instance.new("SpecialMesh", shipwi)
  158. mesh.MeshType = "Wedge"
  159. local shipwi2 = P:Clone()
  160. shipwi2.Parent = mdl
  161. shipwi2.Size = Vector3.new(0.7,0.7,0.84)
  162. shipwi2.Material = "SmoothPlastic"
  163. shipwi2.BrickColor = BrickColor.new("Pastel blue")
  164. shipwi2.Reflectance = 0.6
  165. local mesh = Instance.new("SpecialMesh", shipwi2)
  166. mesh.MeshType = "Wedge"
  167.  
  168. shadow = P:Clone()
  169. shadow.Parent = mdl
  170. shadow.Name = "Shadow"
  171. shadow.Material = "SmoothPlastic"
  172. shadow.BrickColor = BrickColor.new("Really black")
  173. local mesh = Instance.new("SpecialMesh",shadow)
  174. mesh.MeshType = "Sphere"
  175.  
  176. TrailParts = {}
  177. table.insert(TrailParts,{shipp,1,{},cam.CoordinateFrame.p,CFrame.new(0,0,1),0.5,18})
  178. table.insert(TrailParts,{shipwing1,1,{},cam.CoordinateFrame.p,CFrame.new(0,0.45,1),0.3,15})
  179. table.insert(TrailParts,{shipwing2,1,{},cam.CoordinateFrame.p,CFrame.new(0,0.45,1),0.3,15})
  180. for _, V in pairs(TrailParts) do
  181. for i = 1, V[7] do
  182. local p = P:Clone()
  183. local mesh = Instance.new("SpecialMesh", p)
  184. mesh.MeshId = "http://www.roblox.com/asset/?id=9856898"
  185. mesh.TextureId = "http://www.roblox.com/asset/?id=48358980"
  186. p.BrickColor = BrickColor.new("Dark stone grey")
  187. table.insert(V[3],p)
  188. end
  189. end
  190.  
  191. function ReposParts()
  192. shipwing1.CFrame = shipp.CFrame * CFrame.new(-1.1,-0.195,-0.14) * CFrame.Angles(0,0,math.pi/2)
  193. shipwing2.CFrame = shipp.CFrame * CFrame.new(1.1,-0.195,-0.14) * CFrame.Angles(0,0,-math.pi/2)
  194. shipwing21.CFrame = shipp.CFrame * CFrame.new(-1.05,-0.34,-0.45) * CFrame.Angles(0,0,math.pi/2)
  195. shipwing22.CFrame = shipp.CFrame * CFrame.new(1.05,-0.34,-0.45) * CFrame.Angles(0,0,-math.pi/2)
  196. shipwi.CFrame = shipp.CFrame * CFrame.new(0,0,-1.7)
  197. shipwi2.CFrame = shipwi.CFrame * CFrame.new(0,0.015,-0.015)
  198. campart.CFrame = shipp.CFrame + Vector3.new(0,1.5,0)
  199. end
  200. cam.CameraSubject = campart
  201. cam.CameraType = "Track"
  202.  
  203. shipp.CFrame = CFrame.new(NV,Direction) + cam.CoordinateFrame.p
  204. ReposParts()
  205.  
  206. end
  207.  
  208. AllowTrails = true
  209. end
  210. Build("Speeder")
  211.  
  212. function B1D()
  213. Build("Speeder")
  214. end
  215.  
  216. function RollThatSht(direc)
  217. if Roll == 0 then
  218. for i = 1, 50 do
  219. Roll = (-360 + math.cos(math.pi/50*i) * 360) * direc
  220. wait(0.02)
  221. end
  222. Roll = 0
  223. end
  224. end
  225.  
  226. function KD(key)
  227. if key == "w" then
  228. W = true
  229. elseif key == "s" then
  230. S = true
  231. end
  232.  
  233. local rollpls = 0
  234. if key == DoublePress[1] and tick() - DoublePress[2] < 0.32 then
  235. DoublePress = {nil,0}
  236. if key == "a" then
  237. rollpls = -1
  238. elseif key == "d" then
  239. rollpls = 1
  240. end
  241. end
  242.  
  243. DoublePress = {key,tick()}
  244. if rollpls ~= 0 then
  245. RollThatSht(rollpls)
  246. end
  247. end
  248.  
  249. function KU(key)
  250. if key == "w" then
  251. W = false
  252. elseif key == "s" then
  253. S = false
  254. end
  255. end
  256.  
  257. function Equip()
  258. end
  259.  
  260. function Unequip()
  261. end
  262.  
  263. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  264. mouse.Button1Down:connect(B1D)
  265. mouse.KeyDown:connect(KD)
  266. mouse.KeyUp:connect(KU)
  267.  
  268.  
  269.  
  270. local count = 0
  271. local hue = 0
  272. --game:GetService("RunService").Stepped:connect(function()
  273. while wait(0.02) do
  274.  
  275. ------ Speed --------
  276. local valu = (0.002*MaxSpeed) + ((Speed/MaxSpeed)*Acceleration)
  277. if W == true then
  278. Speed = Speed + valu
  279. elseif S == true then
  280. Speed = Speed - valu
  281. end
  282. if Speed > MaxSpeed then
  283. Speed = MaxSpeed
  284. elseif Speed < MinSpeed then
  285. Speed = MinSpeed
  286. end
  287.  
  288. ------ left/right tilt ---------
  289. local target = 180 + math.floor(math.deg(math.atan2(DesiredDirection.x,DesiredDirection.z)))
  290. local current = 180 + math.floor(math.deg(math.atan2(Direction.x,Direction.z)))
  291. local swing = 0
  292. if math.abs(math.abs(current-target) - 360) > math.abs(target-current) then
  293. swing = target-current
  294. else
  295. swing = (current > target and -(math.abs(current-target) - 360)) or (current < target and math.abs(current-target) - 360)
  296. end
  297.  
  298. DesiredDirection = cam.CoordinateFrame.lookVector
  299. ------ direction smoothening ------
  300. local dir = DesiredDirection.unit
  301. if Direction ~= dir then
  302. if (Direction - dir).magnitude < 0.01 then
  303. Direction = dir
  304. else
  305. local dist = ((dir - Direction).unit * (dir - Direction).magnitude) /10
  306. Direction = (Direction + dist).unit
  307. end
  308. end
  309.  
  310. shipp.CFrame = (CFrame.new(NV,Direction) + shipp.Position + (Direction.unit * Speed)) * CFrame.Angles(0,0,math.rad(Roll) + math.rad(swing/2))
  311. ReposParts()
  312.  
  313. ------ shadow ------
  314. local ghitz, genz = RAY(shipp.Position,Vector3.new(0,-26,0))
  315. local angles = CFrame.new()
  316. if ghitz ~= nil and ghitz.className ~= "Terrain" and ((ghitz.className == "Part" and ghitz.Shape == Enum.PartType.Block) or (ghitz.className ~= "Part" and ghitz:IsA("BasePart"))) then
  317. local wvec,vec = FindSurface(ghitz,genz)
  318. angles = CFrame.new(NV,wvec) * CFrame.Angles(-math.pi/2,0,0)
  319. elseif ghitz ~= nil and (ghitz.className == "Part" and ghitz.Shape == Enum.PartType.Ball) then
  320. angles = (CFrame.new(ghitz.Position, genz) - ghitz.Position) * CFrame.Angles(-math.pi/2,0,0)
  321. end
  322. shadow.CFrame = CFrame.new(genz) * angles
  323. shadow.Transparency = 0.5 + (((shipp.Position - genz).magnitude /26)*0.5)
  324. shadow.Mesh.Scale = (Vector3.new(4.4,0.25,4.4) * 5) * (1-(shipp.Position - genz).magnitude /26)
  325.  
  326. ------- Trails -----------------------
  327. if AllowTrails == true then
  328. count = (count+1)%1
  329. hue = (hue+1) % 360
  330. local rgb = HSV(hue,0.65,0.85)
  331. for _,v in pairs(TrailParts) do
  332. local to = (v[1].CFrame * v[5]).p
  333. if Speed > MinSpeed + 0.2 then
  334. v[2] = (v[2]%#v[3]) + 1
  335. v[3][v[2]].CFrame = CFrame.new((v[4] + to)/2,to) * CFrame.Angles(math.pi/2,math.rad(Roll) + math.rad(swing/2),0)
  336. v[3][v[2]].Mesh.Scale = Vector3.new(v[6],(v[4] - to).magnitude*2,v[6])
  337. v[3][v[2]].Mesh.VertexColor = Vector3.new(rgb.r,rgb.g,rgb.b)
  338. v[3][v[2]].Transparency = 0.15
  339. v[3][v[2]].Parent = game.Players.LocalPlayer.Character
  340. else
  341. v[2] = (v[2]%#v[3]) + 1
  342. v[3][v[2]].Parent = nil
  343. end
  344.  
  345. v[4] = to
  346. end
  347. end
  348.  
  349. end
Add Comment
Please, Sign In to add comment