Advertisement
mathmasterphil

Bunny Ears

Mar 3rd, 2015
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.03 KB | None | 0 0
  1. local ply = game.Players.LocalPlayer
  2. char = ply.Character
  3. torso = char.Torso
  4. head = char.Head
  5. holding = false
  6. RS = game:service'RunService'
  7. rarm,larm = char['Left Arm'],char['Right Arm']
  8. Debris = game:service'Debris'
  9.  
  10. pcall(function() ply.Backpack.Moonbunny:Destroy() end) --- Destroys Tool
  11. hop = Instance.new("HopperBin",ply.Backpack)
  12. hop.Name = 'Moonbunny'
  13. FFS = function(A,B) A:FindFirstChild(B) end ---- FindFirstChild Shortcut
  14.  
  15. pcall(function() char.Sole:Destroy() end) --- Destroys Physical Tool
  16. Weapon = Instance.new("Model",char) Weapon.Name = 'Sole'
  17. cfn,ang,md,mr = CFrame.new,CFrame.Angles,math.rad,math.random --- Some Shortcuts
  18.  
  19. for i,v in pairs(head:children()) do
  20. if v.Name == 'MugSound' then v:Destroy() end
  21. end
  22.  
  23. rw,lw = _,_
  24.  
  25. ---TOOLS---
  26. Add ={ --- Array for handy functions
  27. BG = function(parent)
  28. local bg = Instance.new("BodyGyro",parent)
  29. bg.P = 20e+003
  30. bg.maxTorque = Vector3.new(4e+005,4e+005,4e+005)*math.huge
  31. return bg
  32. end;
  33. BP = function(parent,position)
  34. local bp = Instance.new("BodyPosition",parent)
  35. bp.maxForce = Vector3.new()*math.huge
  36. bp.position = position or parent.Position
  37. return bp
  38. end;
  39. BV = function(parent,force)
  40. local bv = Instance.new("BodyVelocity",parent)
  41. bv.maxForce = Vector3.new()*math.huge
  42. bv.velocity = force
  43. return bv
  44. end;
  45. Sound = function(id,pitch,parent)
  46. local tab = setmetatable({},{
  47. __call = function(t,param) cl = t[1]:Clone() cl.Parent = param return cl end
  48. })
  49. local snd = Instance.new("Sound",char.Head)
  50. snd.Name = 'MugSound'
  51. snd.SoundId = id
  52. snd.Pitch = pitch
  53. table.insert(tab,snd)
  54. function tab:Play()
  55. self[1]:Play()
  56. end
  57. return tab
  58. end;
  59. }
  60. Meshes = {Diamond = 'rbxassetid://9756362'; Spikeball = 'rbxassetid://9982590'; --- MeshIds
  61. Egg = 'rbxassetid://1527559'; Ring = 'rbxassetid://3270017';}
  62. Part = function(x,y,z,color,tr,parent)
  63. local p = Instance.new((tr ~= 1 and 'Part' or 'WedgePart'),parent or Weapon)
  64. p.formFactor = 'Custom'
  65. p.Size = Vector3.new(x,y,z)
  66. p.BrickColor = BrickColor.new(color)
  67. p.CanCollide = false
  68. p.TopSurface,p.BottomSurface = 0,0
  69. return p
  70. end
  71. Mesh = function(par,num,x,y,z)
  72. local msh = _
  73. if num == 1 then msh = Instance.new("CylinderMesh",par)
  74. elseif num == 2 then msh = Instance.new("SpecialMesh",par) msh.MeshType = 3
  75. elseif num == 3 then msh = Instance.new("BlockMesh",par)
  76. elseif type(num) == 'string' then msh = Instance.new("SpecialMesh",par) msh.MeshId = num
  77. end
  78. msh.Scale = Vector3.new(x,y,z)
  79. return msh
  80. end
  81. Weld = function(p0,p1,x,y,z,rx,ry,rz,par)
  82. p0.Position = p1.Position
  83. local w = Instance.new('Motor',par or p0)
  84. w.Part0 = p0
  85. w.Part1 = p1
  86. w.C1 = CFrame.new(x,y,z)*CFrame.Angles(rx,ry,rz)
  87. return w
  88. end
  89. Lock = function(which) --- For using Animation
  90. local result = {rw=false,lw=false}
  91. if which == 'R' then
  92. if not rw then
  93. rabr = Part(1,1,1,'White',0) rabr.Transparency = 1
  94. rabr.Position = torso.Position
  95. rw = Weld(rabr,torso,1.5,.5,0,0,0,0) rw.Parent = Weapon
  96. w = Instance.new("Weld",Weapon)
  97. w.Part0,w.Part1 = char['Right Arm'],rabr
  98. w.C1 = CFrame.new(0,-.5,0)
  99. else
  100. rabr:Destroy()
  101. rw = _
  102. end
  103. elseif which == 'L' then
  104. if not lw then
  105. labr = Part(1,1,1,'White',0) labr.Transparency = 1
  106. labr.Position = torso.Position
  107. lw = Weld(labr,torso,-1.5,.5,0,0,0,0) lw.Parent = Weapon
  108. w = Instance.new("Weld",Weapon)
  109. w.Part0,w.Part1 = char['Left Arm'],labr
  110. w.C1 = CFrame.new(0,-.5,0)
  111. else
  112. labr:Destroy()
  113. lw = _
  114. end
  115. elseif which == _ then
  116. if rw then result.rw = true end
  117. if lw then result.lw = true end
  118. end
  119. return result
  120. end
  121. tw = function(Weld, Stop, Step,a) --- TweenWeld function
  122. local func = function()
  123. local Start = Weld.C0
  124. local X1, Y1, Z1 = Start:toEulerAnglesXYZ()
  125. local Stop = Stop
  126. local X2, Y2, Z2 = Stop:toEulerAnglesXYZ()
  127.  
  128. for i = 0, 1, Step or .1 do
  129. Weld.C0 = CFrame.new( (Start.p.X * (1 - i)) + (Stop.p.X * i),
  130. (Start.p.Y * (1 - i)) + (Stop.p.Y * i),
  131. (Start.p.Z * (1 - i)) + (Stop.p.Z * i)) * CFrame.fromEulerAnglesXYZ(
  132. (X1 * (1 - i)) + (X2 * i), (Y1 * (1 - i)) + (Y2 * i),
  133. (Z1 * (1 - i)) + (Z2 * i) )
  134. wait()
  135. end
  136.  
  137. Weld.C0 = Stop
  138. end
  139. if a then coroutine.wrap(function() func() end)() else func() end
  140. end
  141. SFX = {
  142. Ring = function(cf,radius,color,snd) -- Effect used when starting flying (default radius 30)
  143. local ring = Part(1,1,1,color or 'New Yeller',0) ring.Anchored = true
  144. local msh = Mesh(ring,Meshes.Ring,1,1,1)
  145. ring.CFrame = cf
  146. if snd then snd:Play() elseif snd == _ then Whine_snd:Play() end
  147. coroutine.wrap(function()
  148. for i = 1,radius or 30 do wait()
  149. msh.Scale = Vector3.new(i,i,1)
  150. ring.Transparency = i/(radius or 30)
  151. end
  152. ring:Destroy()
  153. end)()
  154. end;
  155. Sphere = function(cf,color,radius)
  156. local ball = Part(1,1,1,color,0) ball.Anchored = true
  157. ball.CFrame = cf
  158. local msh = Mesh(ball,2,1,1,1)
  159. coroutine.wrap(function()
  160. for i = 1,radius do wait()
  161. wait()
  162. msh.Scale = Vector3.new(i,i,i)
  163. ball.Transparency = i/radius
  164. end
  165. ball:Destroy() end)();
  166. end;
  167. }
  168. -----------
  169.  
  170. --SOUNDS--
  171. Whine_snd = Add.Sound("http://www.roblox.com/Asset/?id=3264923",1)
  172. Swing_snd = Add.Sound("http://www.roblox.com/Asset/?id=10209645",1)
  173. Boom_snd = Add.Sound("http://www.roblox.com/Asset/?id=3087031",2.5)
  174. Fire_snd = Add.Sound("http://www.roblox.com/Asset/?id=2760979",1)
  175. Hit_snd = Add.Sound("http://www.roblox.com/Asset/?id=2785493",1) Hit_snd.Volume = 120
  176. ----------
  177.  
  178. ---EARS---
  179. p = Part(1,2,.5,'White',0)
  180. Weld(p,head,.8,1.25,0,0,0,md(-30))
  181. Mesh(p,2,1,1,1)
  182. p2 = Part(.8,1.8,.4,'Pink',0)
  183. Weld(p2,p,0,-.1,-.1,0,0,0)
  184. Mesh(p2,2,1,1,1)
  185.  
  186. p = Part(1,2,.5,'White',0)
  187. Weld(p,head,-.8,1.25,0,0,0,md(30))
  188. Mesh(p,2,1,1,1)
  189. p2 = Part(.8,1.8,.4,'Pink',0)
  190. Weld(p2,p,0,-.1,-.1,0,0,0)
  191. Mesh(p2,2,1,1,1)
  192. ----------
  193.  
  194. function Clear() ---- Removes Eggs
  195. for i,v in pairs(EggList) do v:Destroy() end
  196. EggList = {}
  197. end
  198.  
  199. EggList = {} --- Contains Eggs
  200. function SpawnEgg() ---- Spawn's Egg
  201. local egg = Part(10,10,10,'Black',0) egg.CanCollide = true
  202. egg.Shape = 0
  203. egg.CFrame = torso.CFrame*cfn(0,0,6)
  204. msh = Mesh(egg,Meshes.Egg,4,4,4) msh.TextureId = 'http://www.roblox.com/asset/?id=57202933'
  205. egg.Elasticity = 1
  206. egg.Friction = 0
  207. egg.RotVelocity = Vector3.new(40,-30,40)
  208. egg.Touched:connect(function(hit)
  209. local hum = hit.Parent:FindFirstChild('Humanoid')
  210. if hum and hum.Parent ~= char then
  211. egg.Velocity = cfn(hum.Torso.Position,egg.Position).lookVector*-300
  212. msh.VertexColor = Vector3.new(1,0,0)
  213. wait(.1)
  214. msh.VertexColor = Vector3.new(1,1,1)
  215. else
  216. egg.Velocity = Vector3.new(math.random(-10,10),30,math.random(-10,10))
  217. egg.RotVelocity = Vector3.new(0,0,100)
  218. end
  219. end)
  220. table.insert(EggList,egg)
  221. end
  222.  
  223. bp = _
  224. last_atk = 0
  225.  
  226. flying = false
  227. function Float() --- Floating function
  228. if bp and not flying then bp:Destroy() bp = _ Lock'R' Lock'L' return end --- Stops Floating
  229. local function CheckHeight() local result = _ --- Check's height from nearest object
  230. local r = Ray.new(torso.Position,Vector3.FromNormalId(Enum.NormalId.Bottom)*500)
  231. local o,p = Workspace:FindPartOnRay(r,char)
  232. if o and p then
  233. result = (torso.Position-p).magnitude
  234. end
  235. return result
  236. end
  237. jumping = char.Humanoid.Jump
  238.  
  239. t = RS.Stepped:wait()
  240. if (t - last_atk < .5 and not bp) or ((CheckHeight() == _ or CheckHeight() > 5) and not bp) then --- Logic
  241. bp = Add.BP(torso)
  242. Lock'R' Lock'L' rw.C0 = FloatingR lw.C0 = FloatingL
  243. end
  244.  
  245. last_atk = t
  246. end
  247.  
  248. flying = false
  249. FloatingR = cfn()*ang(0,0,md(-22.5))
  250. FloatingL = cfn()*ang(0,0,md(22.5))
  251. function Fly(mouse) --- Flying function
  252. if bp then
  253. local bg = Add.BG(torso)
  254. rw.C0 = cfn()*ang(md(50),md(-45),0) lw.C0 = cfn()*ang(md(50),md(45),0)
  255. flying = true
  256. Delay(.1,function() SFX.Ring( (torso.CFrame*cfn(0,-4,0))*ang(math.pi/2,0,0) ) end)
  257. while (flying and bp) do wait()
  258. bp.position = torso.Position+(torso.Position-mouse.hit.p).unit*-10
  259. bg.cframe = cfn(torso.Position,mouse.hit.p)*ang(md(-20),0,0)
  260. end
  261. flying = false
  262. bg:Destroy()
  263. rw.C0 = FloatingR lw.C0 = FloatingL
  264. end
  265. end
  266.  
  267. function EggNoJutsu(mouse)
  268. if not rw and not lw then Lock'R' Lock'L' end
  269. holding = true
  270. local bg = Add.BG(torso)
  271. coroutine.wrap(function()
  272. while holding do wait()
  273. if bp then bg.cframe = cfn(torso.Position,mouse.hit.p)
  274. else bg.cframe = cfn(torso.Position,Vector3.new(mouse.hit.p.x,torso.Position.y,mouse.hit.p.z))
  275. end
  276. end
  277. bg:Destroy()
  278. end)()
  279. while holding do
  280. for i = 1,30 do wait() Swing_snd:Play()
  281. rw.C0 = cfn()*ang(md(-mr(50,150)),-md(40),0)
  282. lw.C0 = cfn()*ang(md(-mr(50,150)),md(40),0)
  283. end
  284. SFX.Ring((torso.CFrame*cfn(0,0,-5)),50,'Pink',Boom_snd)
  285. rw.C0 = cfn()*ang(md(-80),md(45),0) lw.C0 = cfn()*ang(md(-80),md(-45),0)
  286. local p = Part(10,10,10,'Black',0) p:BreakJoints()
  287. Mesh(p,Meshes.Egg,5,5,5).TextureId = 'http://www.roblox.com/asset/?id=7958793'
  288. p.CFrame = (torso.CFrame*cfn(0,0,-15))*ang(-math.pi/2,0,0)
  289. Add.BV(p,torso.CFrame.lookVector*300)
  290. p.Touched:connect(function(hit)
  291. if not bp then if hit.Name == 'Base' then return end end
  292. e = Instance.new("Explosion",Workspace)
  293. e.BlastPressure = 0
  294. e.BlastRadius = 100
  295. e.Position = p.Position
  296. p:Destroy()
  297. end)
  298. Debris:AddItem(p,5)
  299. wait(1)
  300. end
  301. if bp and not flying then
  302. rw.C0 = FloatingR lw.C0 = FloatingL
  303. else Lock'R' Lock'L'
  304. end
  305. end
  306.  
  307. r = 5
  308. last_shot = 0
  309. bg2 = _
  310. function Shoot(mouse) attacking = false
  311. Lock'R'
  312. bg2 = Add.BG(torso)
  313. bg2.cframe = cfn(torso.Position,mouse.hit.p)*ang(0,math.pi/2,0)
  314. tw(rw,cfn()*ang(-math.pi/2,math.pi/2,0),.3)
  315. Fire_snd:Play()
  316.  
  317. ---ATT1---
  318.  
  319. for i = -80,80,20 do
  320. local p = Part(1,1,1,'Bright red',0)
  321. p.Transparency = i == 0 and 0 or .5
  322. Mesh(p,Meshes.Egg,1,1,1)
  323. p.CFrame = (torso.CFrame*cfn(5,0,0))*cfn(math.cos(md(i))*r,0,math.sin(md(i))*r)
  324. p.CFrame = cfn(p.Position,torso.Position)*ang(math.pi/2,0,0)
  325. p.Touched:connect(function() SFX.Sphere(p.CFrame,'Bright red',30) Hit_snd(p):Play() p:Destroy() end)
  326. Add.BV(p,(p.CFrame*ang(math.pi/2,0,0)).lookVector*30)
  327. p:BreakJoints()
  328. Debris:AddItem(p,3)
  329. end
  330.  
  331. t = RS.Stepped:wait()
  332.  
  333. if (t-last_shot < .2) then attacking = true
  334. bg2.cframe = cfn(torso.Position,mouse.hit.p)*ang(0,math.pi/2,0)
  335. local p = Part(1,1,1,'Bright red',0)
  336. p.Transparency = i == 0 and 0 or .5
  337. Mesh(p,Meshes.Egg,3,3,3)
  338. p.CFrame = (torso.CFrame*cfn(5,0,0))
  339. p.CFrame = cfn(p.Position,torso.Position)*ang(math.pi/2,0,0)
  340. p.Touched:connect(function() SFX.Sphere(p.CFrame,'Bright red',30) Hit_snd(p):Play() p:Destroy() end)
  341. Add.BV(p,(p.CFrame*ang(math.pi/2,0,0)).lookVector*30)
  342. p:BreakJoints()
  343. Debris:AddItem(p,3)
  344. wait(1)
  345. end
  346. wait(.25)
  347.  
  348. bg2:Destroy() bg2 = _
  349. Lock'R'
  350. last_shot = t
  351. end
  352.  
  353.  
  354. klist = { --- Key Bindings
  355. f = SpawnEgg;
  356. r = Clear;
  357. eq = function(mouse) EggNoJutsu(mouse) end;
  358. q = function(mouse) Shoot(mouse) end;
  359. [string.char(32)] = Float; --- 32 is Space
  360. }
  361.  
  362. hop.Selected:connect(function(mouse) --- Connections
  363. mouse.Button1Down:connect(function() Fly(mouse) end)
  364. mouse.Button1Up:connect(function() flying = false end)
  365. mouse.KeyUp:connect(function(key) for i,v in pairs(klist) do if key == i:sub(1,1) and i:sub(2,2) == 'q' then holding = false end end end)
  366. mouse.KeyDown:connect(function(key)
  367. if attacking then return end
  368. for i,v in pairs(klist) do
  369. if key == i:sub(1,1) then attacking = true v(mouse) attacking = false end
  370. end
  371. end)
  372. end)
  373.  
  374. prev_step = 0
  375. while wait() do --- Effect Loop
  376. t = RS.Stepped:wait()
  377. if not flying and bp then
  378. local p = Part(2,2,2,'White',0)
  379. p.Anchored = true p.Transparency = .5
  380. p.CFrame = (torso.CFrame*cfn(0,-5,0))*ang(math.random(-3,3),math.random(-3,3),math.random(-3,3))
  381. Delay(.1,function() for i = .5,1,.1 do wait() p.Transparency = i end p:Destroy() end)
  382. elseif bp and flying then
  383. local p = Part(2,2,2,'Deep blue',0)
  384. p.Anchored = true p.Transparency = .5
  385. p.CFrame = (torso.CFrame*cfn(0,-5,0))
  386. Delay(.1,function() for i = .5,1,.1 do wait() p.Transparency = i end p:Destroy() end)
  387. end
  388. prevstep = t
  389. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement