Advertisement
firebudgy

Untitled

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