Advertisement
Ak47Studioz

wings

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