minecrafter523

BestBW

Jun 1st, 2016
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.31 KB | None | 0 0
  1. function fly()
  2.  
  3. for i,v in pairs(script:GetChildren()) do
  4. pcall(function() v.Value = "" end)
  5. game:GetService("Debris"):AddItem(v,.1)
  6. end
  7.  
  8. function weld(p0,p1,c0,c1,par)
  9. local w = Instance.new("Weld",p0 or par)
  10. w.Part0 = p0
  11. w.Part1 = p1
  12. w.C0 = c0 or CFrame.new()
  13. w.C1 = c1 or CFrame.new()
  14. return w
  15. end
  16.  
  17. local motors = {}
  18.  
  19. function motor(p0,p1,c0,c1,des,vel,par)
  20. local w = Instance.new("Motor6D",p0 or par)
  21. w.Part0 = p0
  22. w.Part1 = p1
  23. w.C0 = c0 or CFrame.new()
  24. w.C1 = c1 or CFrame.new()
  25. w.MaxVelocity = tonumber(vel) or .05
  26. w.DesiredAngle = tonumber(des) or 0
  27. return w
  28. end
  29.  
  30. function lerp(a,b,c)
  31. return a+(b-a)*c
  32. end
  33.  
  34. function clerp(c1,c2,al)
  35. local com1 = {c1.X,c1.Y,c1.Z,c1:toEulerAnglesXYZ()}
  36. local com2 = {c2.X,c2.Y,c2.Z,c2:toEulerAnglesXYZ()}
  37. for i,v in pairs(com1) do
  38. com1[i] = lerp(v,com2[i],al)
  39. end
  40. return CFrame.new(com1[1],com1[2],com1[3]) * CFrame.Angles(select(4,unpack(com1)))
  41. end
  42.  
  43. function ccomplerp(c1,c2,al)
  44. local com1 = {c1:components()}
  45. local com2 = {c2:components()}
  46. for i,v in pairs(com1) do
  47. com1[i] = lerp(v,com2[i],al)
  48. end
  49. return CFrame.new(unpack(com1))
  50. end
  51.  
  52. function tickwave(time,length,offset)
  53. return (math.abs((tick()+(offset or 0))%time-time/2)*2-time/2)/time/2*length
  54. end
  55.  
  56. function invcol(c)
  57. c = c.Color
  58. return BrickColor.new(Color3.new(1-c.b,1-c.g,1-c.r))
  59. end
  60. local oc = oc or function(...) return ... end
  61. local plr = game.Players.LocalPlayer
  62. local char = plr.Character
  63. local tor = char.Torso
  64. local hum = char.Humanoid
  65. hum.PlatformStand = false
  66. pcall(function()
  67. char.Wings:Destroy()
  68. end)
  69. pcall(function()
  70. char.Angel:Destroy() -- hat
  71. end)
  72. local mod = Instance.new("Model",char)
  73. mod.Name = "Wings"
  74. local special = {
  75. [game.Players.LocalPlayer.Name] = {"Black","Bright red",.5,0,false,Color3.new(1,0,0),Color3.new(0,0,0)},
  76. }
  77. local topcolor = BrickColor.new("Really black")
  78. local feacolor = BrickColor.new("Black")
  79. local ptrans = 0
  80. local pref = 0
  81. local fire = true
  82. local fmcol = Color3.new()
  83. local fscol = Color3.new()
  84. local spec = special[plr.Name:lower()]
  85. if spec then
  86. topcolor,feacolor,ptrans,pref,fire,fmcol,fscol = spec[1] and BrickColor.new(spec[1]) or topcolor,spec[2] and BrickColor.new(spec[2]) or feacolor,spec[3],spec[4],spec[5],spec[6],spec[7]
  87. end
  88. local part = Instance.new("Part")
  89. part.FormFactor = "Custom"
  90. part.Size = Vector3.new(.2,.2,.2)
  91. part.TopSurface,part.BottomSurface = 0,0
  92. part.CanCollide = false
  93. part.BrickColor = BrickColor.new("Black")
  94. part.Transparency = ptrans
  95. part.Reflectance = pref
  96. local ef = Instance.new("Fire",fire and part or nil)
  97. ef.Size = .15
  98. ef.Color = BrickColor.new("Black").Color
  99. ef.SecondaryColor = BrickColor.new("Bright red").Color
  100. part:BreakJoints()
  101. function newpart()
  102. local clone = part:Clone()
  103. clone.Parent = mod
  104. clone:BreakJoints()
  105. return clone
  106. end
  107. local feath = newpart()
  108. feath.BrickColor = feacolor
  109. feath.Transparency = 0
  110. Instance.new("SpecialMesh",feath).MeshType = "Sphere"
  111. function newfeather()
  112. local clone = feath:Clone()
  113. clone.Parent = mod
  114. clone:BreakJoints()
  115. return clone
  116. end
  117.  
  118. ---------- RIGHT WING
  119. local r1 = newpart()
  120. r1.Size = Vector3.new(.3,1.5,.3)*1.2
  121. local rm1 = motor(tor,r1,CFrame.new(.35,.6,.4) * CFrame.Angles(0,0,math.rad(-60)) * CFrame.Angles(math.rad(30),math.rad(-25),0),CFrame.new(0,-.8,0),.1)
  122. local r2 = newpart()
  123. r2.Size = Vector3.new(.4,1.8,.4)*1.2
  124. local rm2 = motor(r1,r2,CFrame.new(0,.75,0) * CFrame.Angles(0,0,math.rad(50)) * CFrame.Angles(math.rad(-30),math.rad(15),0),CFrame.new(0,-.9,0),.1)
  125. local r3 = newpart()r3.Size = Vector3.new(.3,2.2,.3)*1.2
  126. local rm3 = motor(r2,r3,CFrame.new(.1,.9,0) * CFrame.Angles(0,0,math.rad(-140)) * CFrame.Angles(math.rad(-3),0,0),CFrame.new(0,-1.1,0),.1)local r4 = newpart()
  127. r4.Size = Vector3.new(.25,1.2,.25)*1.2
  128. local rm4 = motor(r3,r4,CFrame.new(0,1.1,0) * CFrame.Angles(0,0,math.rad(-10)) * CFrame.Angles(math.rad(-3),0,0),CFrame.new(0,-.6,0),.1)
  129. local feather = newfeather()feather.Mesh.Scale = Vector3.new(1,1,1)
  130. feather.Size = Vector3.new(.4,3,.3)
  131. weld(r4,feather,CFrame.new(-.1,-.3,0),CFrame.new(0,-1.5,0))
  132. feather = newfeather()
  133. feather.Mesh.Scale = Vector3.new(1,1,1)
  134. feather.Size = Vector3.new(.4,2.3,.3)
  135. weld(r4,feather,CFrame.new(.1,-.1,0) * CFrame.Angles(0,math.random()*.1,0),CFrame.new(0,-1.1,0))
  136. feather = newfeather()
  137. feather.Mesh.Scale = Vector3.new(1,1,1)
  138. feather.Size = Vector3.new(.35,2.2,.25)
  139. weld(r4,feather,CFrame.new(.1,-.3,0) * CFrame.Angles(0,math.random()*.1,math.rad(-10)),CFrame.new(0,-1.1,0))
  140. local rf3 = {}
  141. for i=0,7 do
  142. feather = newfeather()
  143. feather.Mesh.Scale = Vector3.new(1,1,1)
  144. feather.Size = Vector3.new(.45,2.2,.35)
  145. table.insert(rf3,motor(r3,feather,CFrame.new(.05,1-i*.285,0) * CFrame.Angles(0,math.random()*.1,math.rad(-25-i*2)),CFrame.new(0,-feather.Size.Y/2,0)))
  146. end
  147. local rf2 = {}
  148. for i=0,6 do
  149. feather = newfeather()
  150. feather.Mesh.Scale = Vector3.new(1,1,1)
  151. feather.Size = Vector3.new(.45,2.2-i*.08,.3)
  152. table.insert(rf2,motor(r2,feather,CFrame.new(.05,.75-i*.26,0) * CFrame.Angles(0,math.random()*.1,math.rad(-75-i*4)),CFrame.new(0,-feather.Size.Y/2,0)))
  153. end
  154. local rf1 = {}
  155. for i=0,6 do
  156. feather = newfeather()
  157. feather.Mesh.Scale = Vector3.new(1,1,1)
  158. feather.Size = Vector3.new(.37,1.65-i*.06,.25)
  159. table.insert(rf1,motor(r1,feather,CFrame.new(.05,.63-i*.21,0) * CFrame.Angles(0,math.random()*.05,math.rad(-75)),CFrame.new(0,-feather.Size.Y/2,0)))
  160. end
  161. ---------- LEFT WING
  162. local l1 = newpart()
  163. l1.Size = Vector3.new(.3,1.5,.3)*1.2
  164. local lm1 = motor(tor,l1,CFrame.new(-.35,.6,.4) * CFrame.Angles(0,0,math.rad(60)) * CFrame.Angles(math.rad(30),math.rad(25),0) * CFrame.Angles(0,-math.pi,0),CFrame.new(0,-.8,0) ,.1)
  165. local l2 = newpart()
  166. l2.Size = Vector3.new(.4,1.8,.4)*1.2
  167. local lm2 = motor(l1,l2,CFrame.new(0,.75,0) * CFrame.Angles(0,0,math.rad(50)) * CFrame.Angles(math.rad(30),math.rad(-15),0),CFrame.new(0,-.9,0),.1)
  168. local l3 = newpart()
  169. l3.Size = Vector3.new(.3,2.2,.3)*1.2
  170. local lm3 = motor(l2,l3,CFrame.new(.1,.9,0) * CFrame.Angles(0,0,math.rad(-140)) * CFrame.Angles(math.rad(3),0,0),CFrame.new(0,-1.1,0),.1)
  171. local l4 = newpart()
  172. l4.Size = Vector3.new(.25,1.2,.25)*1.2
  173. local lm4 = motor(l3,l4,CFrame.new(0,1.1,0) * CFrame.Angles(0,0,math.rad(-10)) * CFrame.Angles(math.rad(3),0,0),CFrame.new(0,-.6,0),.1)
  174. local feather = newfeather()
  175. feather.Mesh.Scale = Vector3.new(1,1,1)
  176. feather.Size = Vector3.new(.4,3,.3)
  177. weld(l4,feather,CFrame.new(-.1,-.3,0),CFrame.new(0,-1.5,0))
  178. feather = newfeather()
  179. feather.Mesh.Scale = Vector3.new(1,1,1)
  180. feather.Size = Vector3.new(.4,2.3,.3)
  181. weld(l4,feather,CFrame.new(.1,-.1,0) * CFrame.Angles(0,math.random()*.1,0),CFrame.new(0,-1.1,0))
  182. feather = newfeather()
  183. feather.Mesh.Scale = Vector3.new(1,1,1)
  184. feather.Size = Vector3.new(.35,2.2,.25)
  185. weld(l4,feather,CFrame.new(.1,-.3,0) * CFrame.Angles(0,math.random()*.1,math.rad(-10)),CFrame.new(0,-1.1,0))
  186. local lf3 = {}
  187. for i=0,7 do
  188. feather = newfeather()
  189. feather.Mesh.Scale = Vector3.new(1,1,1)
  190. feather.Size = Vector3.new(.45,2.2,.35)
  191. table.insert(lf3,motor(l3,feather,CFrame.new(.05,1-i*.285,0) * CFrame.Angles(0,math.random()*.1,math.rad(-25-i*2)),CFrame.new(0,-feather.Size.Y/2,0)))
  192. end
  193. local lf2 = {}
  194. for i=0,6 do
  195. feather = newfeather()
  196. feather.Mesh.Scale = Vector3.new(1,1,1)
  197. feather.Size = Vector3.new(.45,2.2-i*.08,.3)
  198. table.insert(lf2,motor(l2,feather,CFrame.new(.05,.75-i*.26,0) * CFrame.Angles(0,math.random()*.1,math.rad(-75-i*4)),CFrame.new(0,-feather.Size.Y/2,0)))
  199. end
  200. local lf1 = {}
  201. for i=0,6 do
  202. feather = newfeather()
  203. feather.Mesh.Scale = Vector3.new(1,1,1)
  204. feather.Size = Vector3.new(.37,1.65-i*.06,.25)
  205. table.insert(lf1,motor(l1,feather,CFrame.new(.05,.63-i*.21,0) * CFrame.Angles(0,math.random()*.05,math.rad(-75)),CFrame.new(0,-feather.Size.Y/2,0)))
  206. end
  207. local rwing = {rm1,rm2,rm3,rm4}
  208. local lwing = {lm1,lm2,lm3,lm4}
  209. local oc0 = {}
  210. for i,v in pairs(rwing) do
  211. oc0[v] = v.C0
  212. end
  213.  
  214. for i,v in pairs(lwing) do
  215. oc0[v] = v.C0
  216. end
  217.  
  218. function gotResized()
  219. if lastsize then
  220. if tor.Size == lastsize then return end -- This shouldn't happen?
  221. local scaleVec = tor.Size/lastsize
  222. for i,v in pairs(oc0) do
  223. oc0[i] = v-v.p+scaleVec*v.p
  224. end
  225. lastsize = tor.Size
  226. end
  227. lastsize = tor.Size
  228. end
  229. tor.Changed:connect(function(p)
  230. if p == "Size" then
  231. gotResized()
  232. end
  233. end)
  234. gotResized()
  235. local idle = {0,0.5,-.2,0; .05,.05,.1,.05; -.6,-1.5,.1,0;}--0,.3,0,0
  236. local outlow = {-.7,-.2,1.8,0; .3,.05,.1,.05; .2,0,0,0}
  237. local outhigh = {.5,-.2,1.8,0; .3,.05,.1,.05; .2,0,0,0}
  238. local veryhigh = {.9,-.3,1.9,0; .3,.05,.1,.05; .2,0,0,0}
  239. local flap1 = {-.3,.3,1.1,-.2; .3,.05,.1,.05; .2,-.6,0,0}
  240. local divebomb = {0,.2,.4,-.7; .3,.05,.1,.05; 0,-.5,-.6,0}
  241.  
  242. function setwings(tab,time)
  243. time = time or 10
  244. for i=1,4 do
  245. rwing[i].DesiredAngle = tab[i]
  246. lwing[i].DesiredAngle = tab[i]
  247. rwing[i].MaxVelocity = math.abs(tab[i]-rwing[i].CurrentAngle)/time
  248. lwing[i].MaxVelocity = math.abs(tab[i]-lwing[i].CurrentAngle)/time
  249. local rcf = oc0[rwing[i]] * (tab[12+i] or CFrame.new())
  250. local lcf = oc0[lwing[i]] * (tab[12+i] or CFrame.new())
  251. end
  252. for i,v in pairs(rf1) do
  253. v.DesiredAngle = tab[9]
  254. v.MaxVelocity = math.abs(v.DesiredAngle-v.CurrentAngle)/time
  255. end
  256. for i,v in pairs(lf1) do
  257. v.DesiredAngle = tab[9]
  258. v.MaxVelocity = math.abs(v.DesiredAngle-v.CurrentAngle)/time
  259. end
  260. for i,v in pairs(rf2) do
  261. v.DesiredAngle = tab[10]
  262. v.MaxVelocity = math.abs(v.DesiredAngle-v.CurrentAngle)/time
  263. end
  264. for i,v in pairs(lf2) do
  265. v.DesiredAngle = tab[10]
  266. v.MaxVelocity = math.abs(v.DesiredAngle-v.CurrentAngle)/time
  267. end
  268. for i,v in pairs(rf3) do
  269. v.DesiredAngle = tab[11]
  270. v.MaxVelocity = math.abs(v.DesiredAngle-v.CurrentAngle)/time
  271. end
  272. for i,v in pairs(lf3) do
  273. v.DesiredAngle = tab[11]
  274. v.MaxVelocity = math.abs(v.DesiredAngle-v.CurrentAngle)/time
  275. end
  276. end
  277. setwings(outhigh,1)
  278. flying = false
  279. moving = false
  280. for i,v in pairs(tor:GetChildren()) do
  281. if v.ClassName:lower():match("body") then
  282. v:Destroy()
  283. end
  284. end
  285. local ctor = tor:Clone()
  286. ctor:ClearAllChildren()
  287. ctor.Name = "cTorso"
  288. ctor.Transparency = 1
  289. ctor.CanCollide = false
  290. ctor.FormFactor = "Custom"
  291. ctor.Size = Vector3.new(.2,.2,.2)
  292. ctor.Parent = mod
  293. weld(tor,ctor)
  294. local bg = Instance.new("BodyGyro",ctor)
  295. bg.maxTorque = Vector3.new()
  296. bg.P = 15000
  297. bg.D = 1000
  298. local bv = Instance.new("BodyVelocity",ctor)
  299. bv.maxForce = Vector3.new()
  300. bv.P = 15000
  301. vel = Vector3.new()
  302. cf = CFrame.new()
  303. flspd = 0
  304. keysdown = {}
  305. keypressed = {}
  306. ktime = {}
  307. descendtimer = 0
  308. jumptime = tick()
  309. hum.Jumping:connect(function()
  310. jumptime = tick()
  311. end)
  312. cam = workspace.CurrentCamera
  313. kd = plr:GetMouse().KeyDown:connect(oc(function(key)
  314. keysdown[key] = true
  315. keypressed[key] = true
  316. if key == "q" then
  317. descendtimer = tick()
  318. elseif key == " " and not hum.Jump then
  319. jumptime = tick()
  320. elseif (key == "a" or key == "d") and ktime[key] and tick()-ktime[key] < .3 and math.abs(reqrotx) < .3 then
  321. reqrotx = key == "a" and math.pi*2 or -math.pi*2
  322. end
  323. ktime[key] = tick()
  324. end))
  325.  
  326. ku = plr:GetMouse().KeyUp:connect(function(key)
  327. keysdown[key] = false
  328. if key == " " then
  329. descendtimer = tick()
  330. end
  331. end)
  332. function mid(a,b,c)
  333. return math.max(a,math.min(b,c or -a))
  334. end
  335. function bn(a)
  336. return a and 1 or 0
  337. end
  338. function gm(tar)
  339. local m = 0
  340. for i,v in pairs(tar:GetChildren()) do
  341. if v:IsA("BasePart") then
  342. m = m + v:GetMass()
  343. end
  344. m = m + gm(v)
  345. end
  346. return m
  347. end
  348. reqrotx = 0
  349. local grav = 196.2
  350. local con
  351. con = game:GetService("RunService").Stepped:connect(oc(function()
  352. --[[if not mod:IsDescendantOf(workspace) then
  353. pcall(function() kd:disconnect() end)
  354. pcall(function() ku:disconnect() end)
  355. bg:Destroy()
  356. bv:Destroy()
  357. con:disconnect()
  358. script:Destroy()
  359. return
  360. end]]
  361. local obvel = tor.CFrame:vectorToObjectSpace(tor.Velocity)
  362. local sspd, uspd,fspd = obvel.X,obvel.Y,obvel.Z
  363. if flying then
  364. local lfldir = fldir
  365. fldir = cam.CoordinateFrame:vectorToWorldSpace(Vector3.new(bn(keysdown.d)-bn(keysdown.a),0,bn(keysdown.s)-bn(keysdown.w))).unit
  366. local lmoving = moving
  367. moving = fldir.magnitude > .1
  368. if lmoving and not moving then
  369. idledir = lfldir*Vector3.new(1,0,1)
  370. descendtimer = tick()
  371. end
  372. local dbomb = fldir.Y < -.6 or (moving and keysdown["1"])
  373. if moving and keysdown["0"] and lmoving then
  374. fldir = (Vector3.new(lfldir.X,math.min(fldir.Y,lfldir.Y+.01)-.1,lfldir.Z)+(fldir*Vector3.new(1,0,1))*.05).unit
  375. end
  376. local down = tor.CFrame:vectorToWorldSpace(Vector3.new(0,-1,0))
  377. local descending = (not moving and keysdown["q"] and not keysdown[" "])
  378. cf = ccomplerp(cf,CFrame.new(tor.Position,tor.Position+(not moving and idledir or fldir)),keysdown["0"] and .02 or .07)
  379. local gdown = not dbomb and cf.lookVector.Y < -.2 and tor.Velocity.unit.Y < .05
  380. hum.PlatformStand = true
  381. bg.maxTorque = Vector3.new(1,1,1)*9e5
  382. local rotvel = CFrame.new(Vector3.new(),tor.Velocity):toObjectSpace(CFrame.new(Vector3.new(),fldir)).lookVector
  383. bg.cframe = cf * CFrame.Angles(not moving and -.1 or -math.pi/2+.2,moving and mid(-2.5,rotvel.X/1.5) + reqrotx or 0,0)
  384. reqrotx = reqrotx - reqrotx/10
  385. bv.maxForce = Vector3.new(1,1,1)*9e4*.5
  386. local anioff =(bn(keysdown[" "])-bn(keysdown["q"]))/2
  387. local ani = tickwave(1.5-anioff,1)
  388. bv.velocity = bv.velocity:Lerp(Vector3.new(0,bn(not moving)*-ani*15+(descending and math.min(20,tick()-descendtimer)*-8 or bn(keysdown[" "])-bn(keysdown["q"]))*15,0)+vel,.6)
  389. vel = moving and cf.lookVector*flspd or Vector3.new()
  390. flspd = math.min(120,lerp(flspd,moving and (fldir.Y<0 and flspd+(-fldir.Y)*grav/60 or math.max(50,flspd-fldir.Y*grav/300)) or 60,.4))
  391. setwings(moving and (gdown and outlow or dbomb and divebomb) or (descending and veryhigh or flap1),15)
  392. for i=1,4 do
  393. --CFrame.Angles(-.5+bn(i==3)*2.4+bn(i==4)*.5,.1+bn(i==2)*.5-bn(i==3)*1.1,bn(i==3)*.1)
  394. rwing[i].C0 = clerp(rwing[i].C0,oc0[rwing[i]] * (gdown and CFrame.new() or dbomb and CFrame.Angles(-.5+bn(i==3)*.4+bn(i==4)*.5,.1+bn(i==2)*.5-bn(i==3)*1.1,bn(i==3)*.1) or descending and CFrame.Angles(.3,0,0) or CFrame.Angles((i*.1+1.5)*ani,ani*-.5,1*ani)),descending and .8 or .2)
  395. lwing[i].C0 = clerp(lwing[i].C0,oc0[lwing[i]] * (gdown and CFrame.new() or dbomb and CFrame.Angles(-(-.5+bn(i==3)*.4+bn(i==4)*.5),-(.1+bn(i==2)*.5-bn(i==3)*1.1),bn(i==3)*.1) or descending and CFrame.Angles(-.3,0,0) or CFrame.Angles(-(i*.1+1.5)*ani,ani*.5,1*ani)),descending and .8 or .2)
  396. end
  397. local hit,ray = workspace:FindPartOnRayWithIgnoreList(Ray.new(tor.Position,Vector3.new(0,-3.5+math.min(0,bv.velocity.y)/30,0)),{char})
  398. if hit and down.Y < -.85 and tick()-flystart > 1 then
  399. flying = false
  400. hum.PlatformStand = false
  401. tor.Velocity = Vector3.new()
  402. end
  403. else
  404. bg.maxTorque = Vector3.new()
  405. bv.maxForce = Vector3.new()
  406. local ani = tickwave(walking and .8 or 4.5,1)
  407. setwings(idle,10)
  408. local x,y,z = fspd/160,uspd/700,sspd/900
  409. for i=1,4 do
  410. rwing[i].C0 = clerp(rwing[i].C0,oc0[rwing[i]] * CFrame.Angles(ani*.1 + -mid(-.1,x),0 + -mid(-.1,y) + bn(i==2)*.6,ani*.02 + -mid(-.1,z)),.2)
  411. lwing[i].C0 = clerp(lwing[i].C0,oc0[lwing[i]] * CFrame.Angles(ani*-.05 + mid(-.1,x),0 + mid(-.1,y) + -bn(i==2)*.6,ani*.02 + mid(-.1,z)),.2)
  412. end
  413. if keypressed[" "] and not flying and (tick()-jumptime > .05 and (tick()-jumptime < 3 or hum.Jump)) then
  414. vel = Vector3.new(0,50,0)
  415. bv.velocity = vel
  416. idledir = cam.CoordinateFrame.lookVector*Vector3.new(1,0,1)
  417. cf = tor.CFrame * CFrame.Angles(-.01,0,0)
  418. tor.CFrame = cf
  419. bg.cframe = cf
  420. flystart = tick()
  421. flying = true
  422. end
  423. end
  424. keypressed = {}
  425. end))
  426.  
  427. end fly()
Add Comment
Please, Sign In to add comment