Advertisement
SetsunaElysia

Machine Face

Jan 20th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.04 KB | None | 0 0
  1. local pjts = {}
  2. function FireProjectile(origin, velocity, raycallback, ignore, draw)
  3. table.insert(pjts,{origin, origin, velocity, raycallback, ignore, draw})
  4. end
  5. local player = game:GetService("Players").LocalPlayer
  6. local mouse = player:GetMouse()
  7. local mousedown = false
  8. local downtime = 0
  9. local spin = false
  10. local selected = false
  11. local swagbullets = 200
  12. local neck = player.Character.Torso.Neck
  13. local neckc0 = neck.C0
  14. local bin = Instance.new("HopperBin", player.Backpack)
  15. bin.Name = "Machine Face"
  16. local staspin = Instance.new("Sound", player.Character.Head)
  17. staspin.SoundId = "http://roblox.com/asset/?id=10209788"
  18. local stospin = Instance.new("Sound", player.Character.Head)
  19. stospin.SoundId = "http://roblox.com/asset/?id=10209786"
  20. local sping = Instance.new("Sound", player.Character.Head)
  21. sping.SoundId = "http://roblox.com/asset/?id=10209780"
  22. sping.Looped = true
  23. local bang = Instance.new("Sound", player.Character.Head)
  24. bang.SoundId = "http://roblox.com/asset/?id=10209776"
  25. bang.Looped = true
  26. local clicking = Instance.new("Sound", player.Character.Head)
  27. clicking.SoundId = "http://roblox.com/asset/?id=10209771"
  28. clicking.Looped = true
  29. local face = nil
  30. if player.Character.Head:FindFirstChild("face") then
  31. face = player.Character.Head.face:clone()
  32. end
  33. local controlpart = Instance.new("Part", player.Character)
  34. controlpart.Anchored = false
  35. controlpart.CanCollide = false
  36. controlpart.TopSurface = 0
  37. controlpart.BottomSurface = 0
  38. controlpart.FormFactor = "Custom"
  39. controlpart.Size = Vector3.new(0,0,0)
  40. controlpart.Transparency = 1
  41. local muzzle = Instance.new("Part", player.Character)
  42. muzzle.Anchored = false
  43. muzzle.CanCollide = false
  44. muzzle.TopSurface = 0
  45. muzzle.BottomSurface = 0
  46. muzzle.FormFactor = "Custom"
  47. muzzle.Size = Vector3.new(0,0,0)
  48. muzzle.Transparency = 1
  49. local casething = Instance.new("Part", player.Character)
  50. casething.Anchored = false
  51. casething.CanCollide = false
  52. casething.TopSurface = 0
  53. casething.BottomSurface = 0
  54. casething.FormFactor = "Custom"
  55. casething.Size = Vector3.new(0.5,0.3,0.7)
  56. casething.BrickColor = BrickColor.new("Really black")
  57. local control = Instance.new("Weld", controlpart)
  58. control.Part0 = player.Character.Head
  59. control.Part1 = controlpart
  60. control.C0 = CFrame.new(0,0,1)
  61. local muzweld = Instance.new("Weld", controlpart)
  62. muzweld.Part0 = player.Character.Head
  63. muzweld.Part1 = muzzle
  64. muzweld.C0 = CFrame.new(0,0.2,-1.4)
  65. local ctweld = Instance.new("Weld", controlpart)
  66. ctweld.Part0 = player.Character.Head
  67. ctweld.Part1 = casething
  68. ctweld.C0 = CFrame.new(0,0,0.1)
  69. local muzflash = Instance.new("PointLight", muzzle)
  70. muzflash.Range = 10
  71. muzflash.Color = Color3.new(1,0.8,0)
  72. muzflash.Enabled = false
  73. for i = 0,300,60 do
  74. local mpart = Instance.new("Part", player.Character)
  75. mpart.Anchored = false
  76. mpart.CanCollide = false
  77. mpart.TopSurface = 0
  78. mpart.BottomSurface = 0
  79. mpart.FormFactor = "Custom"
  80. mpart.Size = Vector3.new(0.2,1,0.2)
  81. mpart.BrickColor = BrickColor.new("Black")
  82. Instance.new("CylinderMesh",mpart)
  83. local weld = Instance.new("Weld", mpart)
  84. weld.Part0 = controlpart
  85. weld.Part1 = mpart
  86. weld.C0 = CFrame.new(0,0,-1) * CFrame.Angles(math.rad(90),0,0) * CFrame.Angles(0,math.rad(i),0) * CFrame.new(0,0,0.2)
  87. end
  88. local dpart = Instance.new("Part", player.Character)
  89. dpart.Anchored = false
  90. dpart.CanCollide = false
  91. dpart.TopSurface = 0
  92. dpart.BottomSurface = 0
  93. dpart.FormFactor = "Custom"
  94. dpart.Size = Vector3.new(0.7,0.2,0.7)
  95. dpart.BrickColor = BrickColor.new("Black")
  96. Instance.new("CylinderMesh",dpart).Scale = Vector3.new(1,0.6,1)
  97. local dweld = Instance.new("Weld", dpart)
  98. dweld.Part0 = controlpart
  99. dweld.Part1 = dpart
  100. dweld.C0 = CFrame.new(0,0,-0.9) * CFrame.Angles(math.rad(90),0,0)
  101. local dpart = Instance.new("Part", player.Character)
  102. dpart.Anchored = false
  103. dpart.CanCollide = false
  104. dpart.TopSurface = 0
  105. dpart.BottomSurface = 0
  106. dpart.FormFactor = "Custom"
  107. dpart.Size = Vector3.new(0.7,0.2,0.7)
  108. dpart.BrickColor = BrickColor.new("Black")
  109. Instance.new("CylinderMesh",dpart).Scale = Vector3.new(1,0.6,1)
  110. local dweld = Instance.new("Weld", dpart)
  111. dweld.Part0 = controlpart
  112. dweld.Part1 = dpart
  113. dweld.C0 = CFrame.new(0,0,-1.3) * CFrame.Angles(math.rad(90),0,0)
  114. bin.Selected:connect(function()
  115. local asd = 1
  116. local tcount = 0
  117. if player.Character.Head:FindFirstChild("face") then player.Character.Head.face:Destroy() end
  118. while true do
  119. local dt = wait()
  120. tcount = tcount + dt
  121. asd = 1+math.cos((math.pi/2)+(tcount*4))*1.1
  122. if tcount >= 0.5 then
  123. break
  124. end
  125. control.C0 = CFrame.new(0,0,asd)
  126. end
  127. control.C0 = CFrame.new()
  128. local asd = 0.1
  129. while true do
  130. local dt = wait()
  131. asd = asd + dt
  132. if asd >= 0.3 then
  133. break
  134. end
  135. ctweld.C0 = CFrame.new(0,0,asd)
  136. end
  137. ctweld.C0 = CFrame.new(0,0,0.3)
  138. selected = true
  139. end)
  140. bin.Deselected:connect(function()
  141. selected = false
  142. if spin then
  143. sping:Stop()
  144. staspin:Stop()
  145. bang:Stop()
  146. clicking:Stop()
  147. stospin:Play()
  148. end
  149. spin = false
  150. mousedown = false
  151. local asd = 0.3
  152. while true do
  153. local dt = wait()
  154. asd = asd - dt
  155. if asd <= 0.1 then
  156. break
  157. end
  158. ctweld.C0 = CFrame.new(0,0,asd)
  159. end
  160. ctweld.C0 = CFrame.new(0,0,0.1)
  161. local asd = 0
  162. local tcount = 0
  163. while true do
  164. local dt = wait()
  165. tcount = tcount + dt
  166. asd = 1+math.sin(((tcount-0.1)*4)-(math.pi/2))*1.1
  167. if tcount >= 0.48 then
  168. break
  169. end
  170. control.C0 = CFrame.new(0,0,asd)
  171. end
  172. control.C0 = CFrame.new(0,0,1)
  173. face:clone().Parent = player.Character.Head
  174. end)
  175. mouse.KeyDown:connect(function(key)
  176. if key == "q" and selected then
  177. spin = true
  178. staspin:Play()
  179. coroutine.wrap(function()
  180. wait(0.8)
  181. if spin then
  182. staspin:Stop()
  183. sping:Play()
  184. end
  185. end)()
  186. elseif key == "r" and selected then
  187.  
  188. swagbullets = 200
  189. end
  190. end)
  191. mouse.KeyUp:connect(function(key)
  192. if key == "q" and selected and spin then
  193. spin = false
  194. mousedown = false
  195. sping:Stop()
  196. staspin:Stop()
  197. bang:Stop()
  198. clicking:Stop()
  199. stospin:Play()
  200. end
  201. end)
  202. mouse.Button1Down:connect(function()
  203. if spin then
  204. mousedown = true
  205. bang:Play()
  206. end
  207. end)
  208. mouse.Button1Up:connect(function()
  209. mousedown = false
  210. bang:Stop()
  211. clicking:Stop()
  212. end)
  213. function gethums(part)
  214. local hums = {}
  215. local function scanparent(asd)
  216. local humscan = {}
  217. for _,v in pairs(asd.Parent:GetChildren()) do
  218. if v:IsA("Humanoid") then
  219. table.insert(humscan,v)
  220. end
  221. end
  222. return asd.Parent, humscan
  223. end
  224. local currentasd = part
  225. while true do
  226. if currentasd.Parent ~= workspace then
  227. local parent, humscan = scanparent(currentasd)
  228. hums = {unpack(hums),unpack(humscan)}
  229. currentasd = parent
  230. else
  231. break
  232. end
  233. end
  234. return hums
  235. end
  236. --FireProjectile(player.Character.Head.Position, player.Character.Head.Velocity+mouse.UnitRay.Direction*400, function(self,...) return false end, {player.Character})
  237. while true do
  238. local dt = wait()
  239. local ax,ay,az = player.Character.Torso.CFrame:toEulerAnglesXYZ()
  240. local cx,cy,cz = CFrame.new(Vector3.new(),mouse.UnitRay.Direction):toEulerAnglesXYZ()
  241. neck.C0 = CFrame.new(0,1,0)*(CFrame.Angles(ax,ay,az):inverse())*CFrame.Angles(cx,cy,cz)*CFrame.Angles(-math.pi/2,0,math.pi)
  242. if spin then
  243. control.C0 = control.C0 * CFrame.Angles(0,0,10*dt)
  244. end
  245. if mousedown and spin then
  246. downtime = downtime + dt
  247. else
  248. downtime = 0
  249. end
  250. if downtime >= 0.05 then
  251. muzflash.Enabled = true
  252. for i = 0.05, downtime, 0.05 do
  253. if swagbullets > 0 then
  254. downtime = downtime - 0.05
  255. swagbullets = swagbullets - 1
  256. FireProjectile((muzzle.CFrame).p, player.Character.Head.Velocity+((Vector3.new(math.random()-0.5,math.random()-0.5,math.random()-0.5)*0.05)+mouse.UnitRay.Direction)*250, function(self,opart)
  257. local humans = gethums(opart)
  258. for _,hum in pairs(humans) do
  259. hum:TakeDamage(5)
  260. end
  261. return false
  262. end, {player.Character}, function(p1,p2)
  263. asdpart = Instance.new("Part")
  264. asdpart.Anchored = true
  265. asdpart.CanCollide = false
  266. asdpart.TopSurface = 0
  267. asdpart.BottomSurface = 0
  268. asdpart.FormFactor = "Custom"
  269. asdpart.Size = Vector3.new(1,1,1)
  270. asdpart.BrickColor = BrickColor.new("Bright yellow")
  271. asdpart.Reflectance = 0.5
  272. asdpart.CFrame = CFrame.new(p1:Lerp(p2,0.5),p2)+Vector3.new(100,100,0)
  273. local asdmesh = Instance.new("BlockMesh",asdpart)
  274. asdmesh.Scale = Vector3.new(0.1,0.1,(p1-p2).magnitude)
  275. asdmesh.Offset = ((asdpart.CFrame - asdpart.CFrame.p):inverse() * CFrame.new(-100,-100,0)).p
  276. asdpart.Parent = workspace
  277. coroutine.wrap(function()
  278. local noobfacepartlol = asdpart
  279. wait()
  280. if noobfacepartlol then noobfacepartlol:Destroy() end
  281. end)()
  282. return asdpart
  283. end)
  284. else
  285. if not clicking.IsPlaying then
  286. clicking:Play()
  287. bang:Stop()
  288. end
  289. end
  290. end
  291. coroutine.wrap(function()
  292. if swagbullets <= 0 then
  293. muzflash.Enabled = false
  294. end
  295. wait()
  296. if swagbullets > 0 then
  297. muzflash.Enabled = false
  298. local scr = Instance.new("BillboardGui", muzzle)
  299. scr.Adornee = muzzle
  300. scr.Size = UDim2.new(2, 0, 2, 0)
  301. scr.StudsOffset = Vector3.new(0,0,0.2)
  302. scr.Name = "flash"
  303. local pic = Instance.new("ImageLabel", scr)
  304. pic.Image = "http://www.roblox.com/asset/?id=62701218"
  305. pic.Size = UDim2.new(1, 0, 1, 0)
  306. pic.BorderSizePixel = 0
  307. pic.BackgroundTransparency = 1
  308. game:GetService("Debris"):AddItem(scr,0.1)
  309. local case = Instance.new("Part", player.Character)
  310. case.Name = "BulletShell"
  311. case.Anchored = false
  312. case.CanCollide = true
  313. case.TopSurface = "Smooth"
  314. case.BottomSurface = "Smooth"
  315. case.FormFactor = "Custom"
  316. case.Size = Vector3.new(0.2, 0.4, 0.2)
  317. case.Elasticity = 0
  318. case.Reflectance = 0.1
  319. case.BrickColor = BrickColor.new("Bright yellow")
  320. case.CFrame = player.Character.Head.CFrame * CFrame.new(0,0,0.9) * CFrame.Angles(0,0,math.pi/2)
  321. case.Velocity = Vector3.new(0,11,0)-mouse.UnitRay.Direction*7
  322. local casemesh = Instance.new("CylinderMesh", case)
  323. casemesh.Scale = Vector3.new(0.7, 0.7, 0.7)
  324. game:GetService("Debris"):AddItem(case,0.6)
  325. ctweld.C0 = CFrame.new(0,0,0.7)
  326. wait()
  327. ctweld.C0 = CFrame.new(0,0,0.3)
  328. end
  329. end)()
  330. end
  331. for i,pjt in pairs(pjts) do
  332. pjt[2] = pjt[1]
  333. pjt[1] = pjt[1] + pjt[3]*dt
  334. pjt[3] = pjt[3] - Vector3.new(0,196.2,0)*dt
  335. local pjtray = Ray.new(pjt[2],pjt[1]-pjt[2])
  336. local pjtig = {unpack(pjt[5]),pjt[7]}
  337. for _,opjt in pairs(pjts) do
  338. if opjt[7] then
  339. table.insert(pjtig,opjt[7])
  340. end
  341. end
  342. local hpart, hpos = workspace:FindPartOnRayWithIgnoreList(pjtray, pjtig, false)
  343. if hpart and hpos then
  344. local stillgoes = pjt[4](pjt,hpart,hpos,pjt[3])
  345. if stillgoes then
  346. hpos = pjt[1]
  347. else
  348. pjts[i] = nil
  349. end
  350. end
  351. if pjt[6] then
  352. pjt[7] = pjt[6](pjt[2],hpos)
  353. else
  354. pjt[7] = Instance.new("Part")
  355. pjt[7].Anchored = true
  356. pjt[7].CanCollide = false
  357. pjt[7].TopSurface = 0
  358. pjt[7].BottomSurface = 0
  359. pjt[7].FormFactor = "Custom"
  360. pjt[7].Size = Vector3.new(1,1,1)
  361. pjt[7].CFrame = CFrame.new(pjt[2]:Lerp(hpos,0.5),hpos)+Vector3.new(100,100,0)
  362. local asdmesh = Instance.new("BlockMesh",pjt[7])
  363. asdmesh.Scale = Vector3.new(0.2,0.2,(pjt[2]-hpos).magnitude)
  364. asdmesh.Offset = ((pjt[7].CFrame - pjt[7].CFrame.p):inverse() * CFrame.new(-100,-100,0)).p
  365. pjt[7].Parent = workspace
  366. coroutine.wrap(function()
  367. local noobfacepartlol = pjt[7]
  368. wait()
  369. if noobfacepartlol then noobfacepartlol:Destroy() end
  370. end)()
  371. end
  372. if pjt[1].y < -300 then
  373. pjts[i] = nil
  374. end
  375. end
  376. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement