Advertisement
ghostteen14

Untitled

Feb 20th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.37 KB | None | 0 0
  1. -- This script has convert to FE by who i don't know?
  2.  
  3. -----------------------------------------------------
  4. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  5. local Player,game,owner = owner,game
  6. local RealPlayer = Player
  7. do
  8. print("FE Compatibility code by Joseph Deramus")
  9. local rp = RealPlayer
  10. script.Parent = rp.Character
  11.  
  12. --RemoteEvent for communicating
  13. local Event = Instance.new("RemoteEvent")
  14. Event.Name = "UserInput_Event"
  15.  
  16. --Fake event to make stuff like Mouse.KeyDown work
  17. local function fakeEvent()
  18. local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
  19. t.connect = t.Connect
  20. return t
  21. end
  22.  
  23. --Creating fake input objects with fake variables
  24. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  25. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  26. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  27. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  28. end}
  29. --Merged 2 functions into one by checking amount of arguments
  30. CAS.UnbindAction = CAS.BindAction
  31.  
  32. --This function will trigger the events that have been :Connect()'ed
  33. local function te(self,ev,...)
  34. local t = m[ev]
  35. if t and t._fakeEvent then
  36. for _,f in pairs(t.Functions) do
  37. f(...)
  38. end
  39. end
  40. end
  41. m.TrigEvent = te
  42. UIS.TrigEvent = te
  43.  
  44. Event.OnServerEvent:Connect(function(plr,io)
  45. if plr~=rp then return end
  46. m.Target = io.Target
  47. m.Hit = io.Hit
  48. if not io.isMouse then
  49. local b = io.UserInputState == Enum.UserInputState.Begin
  50. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  51. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  52. end
  53. for _,t in pairs(CAS.Actions) do
  54. for _,k in pairs(t.Keys) do
  55. if k==io.KeyCode then
  56. t.Function(t.Name,io.UserInputState,io)
  57. end
  58. end
  59. end
  60. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  61. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  62. end
  63. end)
  64. Event.Parent = NLS([==[
  65. local Player = game:GetService("Players").LocalPlayer
  66. local Event = script:WaitForChild("UserInput_Event")
  67.  
  68. local Mouse = Player:GetMouse()
  69. local UIS = game:GetService("UserInputService")
  70. local input = function(io,a)
  71. if a then return end
  72. --Since InputObject is a client-side instance, we create and pass table instead
  73. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  74. end
  75. UIS.InputBegan:Connect(input)
  76. UIS.InputEnded:Connect(input)
  77.  
  78. local h,t
  79. --Give the server mouse data 30 times every second, but only if the values changed
  80. --If player is not moving their mouse, client won't fire events
  81. while wait(1/30) do
  82. if h~=Mouse.Hit or t~=Mouse.Target then
  83. h,t=Mouse.Hit,Mouse.Target
  84. Event:FireServer({isMouse=true,Target=t,Hit=h})
  85. end
  86. end]==],Player.Character)
  87.  
  88. ----Sandboxed game object that allows the usage of client-side methods and services
  89. --Real game object
  90. local _rg = game
  91.  
  92. --Metatable for fake service
  93. local fsmt = {
  94. __index = function(self,k)
  95. local s = rawget(self,"_RealService")
  96. if s then return s[k] end
  97. end,
  98. __newindex = function(self,k,v)
  99. local s = rawget(self,"_RealService")
  100. if s then s[k]=v end
  101. end,
  102. __call = function(self,...)
  103. local s = rawget(self,"_RealService")
  104. if s then return s(...) end
  105. end
  106. }
  107. local function FakeService(t,RealService)
  108. t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
  109. return setmetatable(t,fsmt)
  110. end
  111.  
  112. --Fake game object
  113. local g = {
  114. GetService = function(self,s)
  115. return self[s]
  116. end,
  117. Players = FakeService({
  118. LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
  119. },"Players"),
  120. UserInputService = FakeService(UIS,"UserInputService"),
  121. ContextActionService = FakeService(CAS,"ContextActionService"),
  122. }
  123. rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
  124. g.service = g.GetService
  125.  
  126. g.RunService = FakeService({
  127. RenderStepped = _rg:GetService("RunService").Heartbeat,
  128. BindToRenderStep = function(self,name,_,fun)
  129.  
  130. end,
  131. UnbindFromRenderStep = function(self,name)
  132. self._btrs[name]:Disconnect()
  133. end,
  134. },"RunService")
  135.  
  136. setmetatable(g,{
  137. __index=function(self,s)
  138. return _rg:GetService(s) or typeof(_rg[s])=="function"
  139. and function(_,...)return _rg[s](_rg,...)end or _rg[s]
  140. end,
  141. __newindex = fsmt.__newindex,
  142. __call = fsmt.__call
  143. })
  144. --Changing owner to fake player object to support owner:GetMouse()
  145. game,owner = g,g.Players.LocalPlayer
  146. end
  147.  
  148. repeat wait() until game:IsLoaded() and game:service("Players").LocalPlayer.Character ~= nil;
  149. wait(0.4)
  150. for i, v in pairs(game:service("Players").LocalPlayer.Character:children()) do
  151. if v ~= script then
  152. v:Destroy()
  153. end
  154. end
  155.  
  156. local player = game:service("Players").LocalPlayer
  157. local mouse = player:GetMouse()
  158. local cam = workspace.CurrentCamera
  159. local char = player.Character
  160. local Torsoz = char:findFirstChild("Torso")
  161. local NV = Vector3.new()
  162. local Main
  163. local W,S = false,false
  164. local DoublePress = {nil,0}
  165. script.Parent = char
  166.  
  167. local TrailParts = {}
  168. local Acceleration = 0.08
  169. local Speed = 0
  170. local MinSpeed = 0
  171. local MaxSpeed = 3.2
  172. local DesiredDirection = cam.CoordinateFrame.lookVector
  173. local Direction = DesiredDirection
  174. local Roll = 0
  175. local AllowTrails = true
  176.  
  177. script.Name = "AdvFlight"
  178.  
  179. local P = Instance.new("Part")
  180. P.Anchored = true
  181. P.CanCollide = false
  182. P.Name = "Part"
  183. P.formFactor = "Custom"
  184. P.Size = Vector3.new(0.2,0.2,0.2)
  185. P.Locked = true
  186. P.TopSurface = 10
  187. P.BottomSurface = 10
  188. P.FrontSurface = 10
  189. P.BackSurface = 10
  190. P.LeftSurface = 10
  191. P.RightSurface = 10
  192. P.Material = "Pebble"
  193. P.BrickColor = BrickColor.new("White")
  194.  
  195. local shipp
  196. local shadow
  197. local campart
  198.  
  199. function RAY(pos, dir, startpos, endpos, distleft, collidedlist)
  200. collidedlist = collidedlist or {char}
  201. startpos = startpos or pos
  202. distleft = distleft or dir.unit * dir.magnitude
  203. endpos = endpos or pos + distleft
  204. local ray = Ray.new(pos, distleft)
  205. local hitz,enz = workspace:FindPartOnRayWithIgnoreList(ray, collidedlist)
  206. if hitz ~= nil then
  207. if hitz.CanCollide == false then
  208. table.insert(collidedlist, hitz)
  209. local newpos = enz
  210. local newdistleft = distleft - (dir.unit * (pos - newpos).magnitude)
  211. if newdistleft ~= NV then
  212. return RAY(newpos-(dir*0.01), dir, startpos, endpos, newdistleft+(dir*0.01), collidedlist)
  213. end
  214. end
  215. end
  216. return hitz, enz, ray
  217. end
  218.  
  219. function FindSurface(part, position)
  220. local obj = part.CFrame:pointToObjectSpace(position)
  221. local siz = part.Size/2
  222. for i,v in pairs(Enum.NormalId:GetEnumItems()) do
  223. local vec = Vector3.FromNormalId(v)
  224. local wvec = part.CFrame:vectorToWorldSpace(vec)
  225. local vz = (obj)/(siz*vec)
  226. 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
  227. return wvec,vec
  228. end
  229. end
  230. if part.className == "WedgePart" then
  231. return part.CFrame:vectorToWorldSpace(Vector3.new(0,0.707,-0.707)), Vector3.new(0,0.707,-0.707)
  232. end
  233. end
  234.  
  235. function HSV(H,S,V)
  236. H = H % 360
  237. local C = V * S
  238. local H2 = H/60
  239. local X = C * (1 - math.abs((H2 %2) -1))
  240. local color = Color3.new(0,0,0)
  241. if H2 <= 0 then
  242. color = Color3.new(C,0,0)
  243. elseif 0 <= H2 and H2 <= 1 then
  244. color = Color3.new(C,X,0)
  245. elseif 1 <= H2 and H2 <= 2 then
  246. color = Color3.new(X,C,0)
  247. elseif 2 <= H2 and H2 <= 3 then
  248. color = Color3.new(0,C,X)
  249. elseif 3 <= H2 and H2 <= 4 then
  250. color = Color3.new(0,X,C)
  251. elseif 4 <= H2 and H2 <= 5 then
  252. color = Color3.new(X,0,C)
  253. elseif 5 <= H2 and H2 <= 6 then
  254. color = Color3.new(C,0,X)
  255. end
  256. local m = V - C
  257. return Color3.new(color.r + m, color.g + m, color.b + m)
  258. end
  259.  
  260. function Build(shiptype)
  261. AllowTrails = true
  262. for i, v in pairs(char:children()) do
  263. if v.className == "Model" and v.Name == "Ship" then
  264. v:remove()
  265. end
  266. end
  267. for i, v in pairs(TrailParts) do
  268. for _,V in pairs(v[3]) do
  269. V:Destroy()
  270. end
  271. end
  272. local mdl = Instance.new("Model", char)
  273. mdl.Name = "Ship"
  274.  
  275. ------------------------ Speeder Ship Type -----------------------------
  276. if shiptype == "Speeder" then
  277.  
  278. shipp = P:Clone()
  279. shipp.Parent = mdl
  280. shipp.Size = Vector3.new(1,1,2.2)
  281. local shipwing1 = P:Clone()
  282. shipwing1.Parent = mdl
  283. shipwing1.Size = Vector3.new(0.6,1.2,2)
  284. local mesh = Instance.new("SpecialMesh", shipwing1)
  285. mesh.MeshType = "Wedge"
  286. local shipwing2 = shipwing1:Clone()
  287. shipwing2.Parent = mdl
  288. campart = P:Clone()
  289. campart.Transparency = 1
  290. local shipwing21 = P:Clone()
  291. shipwing21.Parent = mdl
  292. shipwing21.Size = Vector3.new(0.32,1.1,2.6)
  293. local mesh = Instance.new("SpecialMesh", shipwing21)
  294. mesh.MeshType = "Wedge"
  295. local shipwing22 = shipwing21:Clone()
  296. shipwing22.Parent = mdl
  297. campart = P:Clone()
  298. campart.Transparency = 1
  299.  
  300. local shipwi = P:Clone()
  301. shipwi.Parent = mdl
  302. shipwi.Size = Vector3.new(1,1,1.2)
  303. local mesh = Instance.new("SpecialMesh", shipwi)
  304. mesh.MeshType = "Wedge"
  305. local shipwi2 = P:Clone()
  306. shipwi2.Parent = mdl
  307. shipwi2.Size = Vector3.new(0.7,0.7,0.84)
  308. shipwi2.Material = "SmoothPlastic"
  309. shipwi2.BrickColor = BrickColor.new("Pastel blue")
  310. shipwi2.Reflectance = 0.6
  311. local mesh = Instance.new("SpecialMesh", shipwi2)
  312. mesh.MeshType = "Wedge"
  313.  
  314. shadow = P:Clone()
  315. shadow.Parent = mdl
  316. shadow.Name = "Shadow"
  317. shadow.Material = "SmoothPlastic"
  318. shadow.BrickColor = BrickColor.new("Really black")
  319. local mesh = Instance.new("SpecialMesh",shadow)
  320. mesh.MeshType = "Sphere"
  321.  
  322. TrailParts = {}
  323. table.insert(TrailParts,{shipp,1,{},cam.CoordinateFrame.p,CFrame.new(0,0,1),0.5,18})
  324. table.insert(TrailParts,{shipwing1,1,{},cam.CoordinateFrame.p,CFrame.new(0,0.45,1),0.3,15})
  325. table.insert(TrailParts,{shipwing2,1,{},cam.CoordinateFrame.p,CFrame.new(0,0.45,1),0.3,15})
  326. for _, V in pairs(TrailParts) do
  327. for i = 1, V[7] do
  328. local p = P:Clone()
  329. local mesh = Instance.new("SpecialMesh", p)
  330. mesh.MeshId = "http://www.roblox.com/asset/?id=9856898"
  331. mesh.TextureId = "http://www.roblox.com/asset/?id=48358980"
  332. p.BrickColor = BrickColor.new("Dark stone grey")
  333. table.insert(V[3],p)
  334. end
  335. end
  336.  
  337. function ReposParts()
  338. shipwing1.CFrame = shipp.CFrame * CFrame.new(-1.1,-0.195,-0.14) * CFrame.Angles(0,0,math.pi/2)
  339. shipwing2.CFrame = shipp.CFrame * CFrame.new(1.1,-0.195,-0.14) * CFrame.Angles(0,0,-math.pi/2)
  340. shipwing21.CFrame = shipp.CFrame * CFrame.new(-1.05,-0.34,-0.45) * CFrame.Angles(0,0,math.pi/2)
  341. shipwing22.CFrame = shipp.CFrame * CFrame.new(1.05,-0.34,-0.45) * CFrame.Angles(0,0,-math.pi/2)
  342. shipwi.CFrame = shipp.CFrame * CFrame.new(0,0,-1.7)
  343. shipwi2.CFrame = shipwi.CFrame * CFrame.new(0,0.015,-0.015)
  344. campart.CFrame = shipp.CFrame + Vector3.new(0,1.5,0)
  345. end
  346. cam.CameraSubject = campart
  347. cam.CameraType = "Track"
  348.  
  349. shipp.CFrame = CFrame.new(NV,Direction) + cam.CoordinateFrame.p
  350. ReposParts()
  351.  
  352. end
  353.  
  354. AllowTrails = true
  355. end
  356. Build("Speeder")
  357.  
  358. function B1D()
  359. Build("Speeder")
  360. end
  361.  
  362. function RollThatSht(direc)
  363. if Roll == 0 then
  364. for i = 1, 50 do
  365. Roll = (-360 + math.cos(math.pi/50*i) * 360) * direc
  366. wait(0.02)
  367. end
  368. Roll = 0
  369. end
  370. end
  371.  
  372. function KD(key)
  373. if key == "w" then
  374. W = true
  375. elseif key == "s" then
  376. S = true
  377. end
  378.  
  379. local rollpls = 0
  380. if key == DoublePress[1] and tick() - DoublePress[2] < 0.32 then
  381. DoublePress = {nil,0}
  382. if key == "a" then
  383. rollpls = -1
  384. elseif key == "d" then
  385. rollpls = 1
  386. end
  387. end
  388.  
  389. DoublePress = {key,tick()}
  390. if rollpls ~= 0 then
  391. RollThatSht(rollpls)
  392. end
  393. end
  394.  
  395. function KU(key)
  396. if key == "w" then
  397. W = false
  398. elseif key == "s" then
  399. S = false
  400. end
  401. end
  402.  
  403. function Equip()
  404. end
  405.  
  406. function Unequip()
  407. end
  408.  
  409. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  410. mouse.Button1Down:connect(B1D)
  411. mouse.KeyDown:connect(KD)
  412. mouse.KeyUp:connect(KU)
  413.  
  414.  
  415.  
  416. local count = 0
  417. local hue = 0
  418. --game:GetService("RunService").Stepped:connect(function()
  419. while wait(0.02) do
  420.  
  421. ------ Speed --------
  422. local valu = (0.002*MaxSpeed) + ((Speed/MaxSpeed)*Acceleration)
  423. if W == true then
  424. Speed = Speed + valu
  425. elseif S == true then
  426. Speed = Speed - valu
  427. end
  428. if Speed > MaxSpeed then
  429. Speed = MaxSpeed
  430. elseif Speed < MinSpeed then
  431. Speed = MinSpeed
  432. end
  433.  
  434. ------ left/right tilt ---------
  435. local target = 180 + math.floor(math.deg(math.atan2(DesiredDirection.x,DesiredDirection.z)))
  436. local current = 180 + math.floor(math.deg(math.atan2(Direction.x,Direction.z)))
  437. local swing = 0
  438. if math.abs(math.abs(current-target) - 360) > math.abs(target-current) then
  439. swing = target-current
  440. else
  441. swing = (current > target and -(math.abs(current-target) - 360)) or (current < target and math.abs(current-target) - 360)
  442. end
  443.  
  444. DesiredDirection = cam.CoordinateFrame.lookVector
  445. ------ direction smoothening ------
  446. local dir = DesiredDirection.unit
  447. if Direction ~= dir then
  448. if (Direction - dir).magnitude < 0.01 then
  449. Direction = dir
  450. else
  451. local dist = ((dir - Direction).unit * (dir - Direction).magnitude) /10
  452. Direction = (Direction + dist).unit
  453. end
  454. end
  455.  
  456. shipp.CFrame = (CFrame.new(NV,Direction) + shipp.Position + (Direction.unit * Speed)) * CFrame.Angles(0,0,math.rad(Roll) + math.rad(swing/2))
  457. ReposParts()
  458.  
  459. ------ shadow ------
  460. local ghitz, genz = RAY(shipp.Position,Vector3.new(0,-26,0))
  461. local angles = CFrame.new()
  462. 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
  463. local wvec,vec = FindSurface(ghitz,genz)
  464. angles = CFrame.new(NV,wvec) * CFrame.Angles(-math.pi/2,0,0)
  465. elseif ghitz ~= nil and (ghitz.className == "Part" and ghitz.Shape == Enum.PartType.Ball) then
  466. angles = (CFrame.new(ghitz.Position, genz) - ghitz.Position) * CFrame.Angles(-math.pi/2,0,0)
  467. end
  468. shadow.CFrame = CFrame.new(genz) * angles
  469. shadow.Transparency = 0.5 + (((shipp.Position - genz).magnitude /26)*0.5)
  470. shadow.Mesh.Scale = (Vector3.new(4.4,0.25,4.4) * 5) * (1-(shipp.Position - genz).magnitude /26)
  471.  
  472. ------- Trails -----------------------
  473. if AllowTrails == true then
  474. count = (count+1)%1
  475. hue = (hue+1) % 360
  476. local rgb = HSV(hue,0.65,0.85)
  477. for _,v in pairs(TrailParts) do
  478. local to = (v[1].CFrame * v[5]).p
  479. if Speed > MinSpeed + 0.2 then
  480. v[2] = (v[2]%#v[3]) + 1
  481. 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)
  482. v[3][v[2]].Mesh.Scale = Vector3.new(v[6],(v[4] - to).magnitude*2,v[6])
  483. v[3][v[2]].Mesh.VertexColor = Vector3.new(rgb.r,rgb.g,rgb.b)
  484. v[3][v[2]].Transparency = 0.15
  485. v[3][v[2]].Parent = game.Players.LocalPlayer.Character
  486. else
  487. v[2] = (v[2]%#v[3]) + 1
  488. v[3][v[2]].Parent = nil
  489. end
  490.  
  491. v[4] = to
  492. end
  493. end
  494.  
  495. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement