Advertisement
PeanutBrickle

Gun

Jun 13th, 2015
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.25 KB | None | 0 0
  1. local lp=game:service'Players'.LocalPlayer
  2. local plr = lp
  3. local player = lp
  4. local chr = lp.Character
  5. local char = chr
  6. local pr=z1
  7. local humanoid = char:WaitForChild("Humanoid")
  8. local db=false
  9.  
  10. BodyParts = {
  11. [1] = "Head";
  12. [2] = "Left Arm";
  13. [3] = "Right Arm";
  14. [4] = "Left Leg";
  15. [5] = "Right Leg";
  16. [6] = "Torso";
  17. }
  18.  
  19. headshots = {208341701, 142347633, 146457047,146594648,153622804,176393385,207764796}
  20.  
  21.  
  22.  
  23.  
  24.  
  25. Services = {
  26. game:service'Players';
  27. game:service'Workspace';
  28. game:service'Lighting';
  29. game:service'ServerStorage';
  30. ['Run'] = game:service'RunService';
  31. }
  32.  
  33. function PlaySound(id, pitch, parent, volume)
  34. if volume == nil then volume=tonumber(1) end
  35. epicsound = Instance.new("Sound")
  36. epicsound.Name = "Epicosound"
  37. epicsound.SoundId = "rbxassetid://"..id
  38. epicsound.Volume = volume
  39. epicsound.Pitch = pitch
  40. epicsound.Looped = false
  41. epicsound.Parent = parent
  42. sbu = epicsound:Clone()
  43. sbu.Parent = Storage
  44. if epicsound.SoundId=="rbxassetid://tt" then -- TELL ME, TELL ME, WHERE DA FREAKS AT!
  45. epicsound.SoundId="rbxassetid://181158033"
  46. elseif epicsound.SoundId=="rbxassetid://fabulous" then -- FA-FA-FABULOUS!
  47. epicsound.SoundId="rbxassetid://191819419"
  48. elseif epicsound.SoundId=="rbxassetid://ufdb" then -- ultimate final death battle(fairy tail XD)
  49. epicsound.SoundId="rbxassetid://153085393"
  50. elseif epicsound.SoundId=="rbxassetid://nnm" then
  51. epicsound.SoundId="rbxassetid://210189234"
  52. elseif epicsound.SoundId=="rbxassetid://tun" then -- tunak tunak tun
  53. epicsound.SoundId="rbxass/setid://162682002"
  54. elseif epicsound.SoundId=="rbxassetid://zelda" then
  55. epicsound.SoundId="rbxassetid://158215156"
  56. elseif epicsound.SoundId=="rbxassetid://cc" then
  57. epicsound.SoundId="rbxassetid://177080835"
  58. end
  59. wait()
  60. epicsound:Play()
  61. game:service'Debris':AddItem(epicsound, 8)
  62. end
  63.  
  64. headshoot = function(part)
  65. local shot=math.random(1, #headshots)
  66. PlaySound(headshots[shot], .9, part)
  67. end
  68.  
  69. local Run = Services['Run']
  70.  
  71. local head = chr[BodyParts[1]]
  72. local larm = chr[BodyParts[2]]
  73. local rarm = chr[BodyParts[3]]
  74. local lleg = chr[BodyParts[4]]
  75. local rleg = chr[BodyParts[5]]
  76. local trso = chr[BodyParts[6]]
  77.  
  78.  
  79. local ls = trso['Left Shoulder']
  80. local rs = trso['Right Shoulder']
  81.  
  82.  
  83. local mouse = plr:GetMouse()
  84.  
  85.  
  86.  
  87. local attacking = false
  88. local attack = 0
  89.  
  90.  
  91. local weld = function(p0, p1,x,y,z,ax,ay,az)
  92. p0.Position = p1.Position
  93. local w=Instance.new("Motor", p0)
  94. w.Part0=p0
  95. w.Part1=p1
  96. w.C0=CFrame.new(x,y,z)*CFrame.Angles(ax,ay,az)
  97. end
  98.  
  99.  
  100.  
  101. mouse = lp:GetMouse()
  102.  
  103.  
  104. function TakeDamage(hum, damage)
  105. hum:TakeDamage(damage)
  106. end
  107.  
  108. function lerp(a,b,c)return a+(b-a)*c end
  109. function lerp2(a,b,c)return a*(1-c)+b*c end
  110. function clerp(c1,c2,al,x)
  111. local com1 = {c1.X,c1.Y,c1.Z,c1:toEulerAnglesXYZ()}local com2 = {c2.X,c2.Y,c2.Z,c2:toEulerAnglesXYZ()}
  112. for i,v in pairs(com1) do if x == true then com1[i] = lerp2(v,com2[i],al) else com1[i] = lerp(v,com2[i],al)end end
  113. return CFrame.new(com1[1],com1[2],com1[3]) * CFrame.Angles(select(4,unpack(com1)))
  114. end
  115.  
  116.  
  117. local z1=Instance.new("Part", rarm)
  118. z1.FormFactor = "Custom"
  119. z1.Size = Vector3.new(1, 1, 2)
  120. z1.Locked = true
  121. z1.CanCollide = false
  122. z1.TopSurface = 0
  123. z1.BottomSurface = 0
  124. z1.FormFactor = 3
  125.  
  126. local z2=Instance.new("Part", larm)
  127. z2.FormFactor = "Custom"
  128. z2.Size = Vector3.new(1, 1, 2)
  129. z2.Locked = true
  130. z2.CanCollide = false
  131. z2.TopSurface = 0
  132. z2.BottomSurface = 0
  133. z2.FormFactor = 3
  134.  
  135.  
  136.  
  137.  
  138. local MaxDamage = 144
  139. local MinDamage = 5
  140. local Ammo=250
  141. local Clip=500
  142. local MaxAmmo=250
  143.  
  144. weld(z1,rarm,0,0.7,-0.9,4.7,0,0)
  145. weld(z2,larm,0,0.7,-0.9,4.7,0,0)
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152. local g1 = Instance.new("ScreenGui", lp.PlayerGui)
  153. g1.Name = "AmmoGui"
  154. local o1 = Instance.new("TextLabel", g1)
  155. o1.BackgroundColor3 = Color3.new(0.368627, 0.0745098, 1)
  156. o1.BackgroundTransparency = 0.69999998807907
  157. o1.BorderColor3 = Color3.new(0.498039, 1, 0.027451)
  158. o1.BorderSizePixel = 3
  159. o1.Name = "Ammo"
  160. o1.Size = UDim2.new(0, 200, 0, 50)
  161. o1.Text = "Ammo: "..Ammo..'/'..MaxAmmo
  162. o1.TextWrapped = true
  163. o1.TextColor3 = Color3.new(0.282353, 0, 1)
  164. o1.TextStrokeColor3 = Color3.new(0.0666667, 1, 0)
  165. o1.TextStrokeTransparency = 0.30000001192093
  166. o1.Font = Enum.Font.ArialBold
  167. o1.FontSize = Enum.FontSize.Size36
  168. local o2 = Instance.new("TextLabel", g1)
  169. o2.BackgroundColor3 = Color3.new(0.368627, 0.0745098, 1)
  170. o2.BackgroundTransparency = 0.69999998807907
  171. o2.BorderColor3 = Color3.new(0.498039, 1, 0.027451)
  172. o2.BorderSizePixel = 3
  173. o2.Name = "Ammo"
  174. o2.Size = UDim2.new(0, 200, 0, 50)
  175. o2.Position=UDim2.new(0, 200, 0, 0)
  176. o2.Text = "Clip: "..Clip
  177. o2.TextWrapped = true
  178. o2.TextColor3 = Color3.new(0.282353, 0, 1)
  179. o2.TextStrokeColor3 = Color3.new(0.0666667, 1, 0)
  180. o2.TextStrokeTransparency = 0.30000001192093
  181. o2.Font = Enum.Font.ArialBold
  182. o2.FontSize = Enum.FontSize.Size36
  183.  
  184. function makeAmmoGui()
  185. g1 = Instance.new("ScreenGui", lp.PlayerGui)
  186. g1.Name = "AmmoGui"
  187. o1 = Instance.new("TextLabel", g1)
  188. o1.BackgroundColor3 = Color3.new(0.368627, 0.0745098, 1)
  189. o1.BackgroundTransparency = 0.69999998807907
  190. o1.BorderColor3 = Color3.new(0.498039, 1, 0.027451)
  191. o1.BorderSizePixel = 3
  192. o1.Name = "Ammo"
  193. o1.Size = UDim2.new(0, 200, 0, 50)
  194. o1.Text = "Ammo: "..Ammo..'/'..MaxAmmo
  195. o1.TextWrapped = true
  196. o1.TextColor3 = Color3.new(0.282353, 0, 1)
  197. o1.TextStrokeColor3 = Color3.new(0.0666667, 1, 0)
  198. o1.TextStrokeTransparency = 0.30000001192093
  199. o1.Font = Enum.Font.ArialBold
  200. o1.FontSize = Enum.FontSize.Size36
  201. o2 = Instance.new("TextLabel", g1)
  202. o2.BackgroundColor3 = Color3.new(0.368627, 0.0745098, 1)
  203. o2.BackgroundTransparency = 0.69999998807907
  204. o2.BorderColor3 = Color3.new(0.498039, 1, 0.027451)
  205. o2.BorderSizePixel = 3
  206. o2.Name = "Ammo"
  207. o2.Size = UDim2.new(0, 200, 0, 50)
  208. o2.Position=UDim2.new(0, 200, 0, 0)
  209. o2.Text = "Clip: "..Clip
  210. o2.TextWrapped = true
  211. o2.TextColor3 = Color3.new(0.282353, 0, 1)
  212. o2.TextStrokeColor3 = Color3.new(0.0666667, 1, 0)
  213. o2.TextStrokeTransparency = 0.30000001192093
  214. o2.Font = Enum.Font.ArialBold
  215. o2.FontSize = Enum.FontSize.Size36
  216. end
  217.  
  218. function Part(Par, Anc, Colli, Tran, Ref, Col, Siz)
  219. local p = Instance.new("Part")
  220. p.formFactor = "Custom"
  221. p.TopSurface = 0
  222. p.BottomSurface = 0
  223. p.Transparency = Tran
  224. p.Reflectance = Ref
  225. p.Anchored = Anc
  226. p.CanCollide = Colli
  227. p.BrickColor = Col
  228. p.Size = Siz
  229. p.Locked = true
  230. p.Parent = Par
  231. p:BreakJoints()
  232. return p
  233. end
  234.  
  235. function Notime(func)
  236. coroutine.resume(coroutine.create(function()
  237. func()
  238. end))
  239. end
  240.  
  241. function Show_Damage(P, D, Area)
  242. local mo = Instance.new("Model")
  243. mo.Name = D
  244. local p = Part(mo, true, false, 0, 0, BrickColor.new("Bright red"), Vector3.new(0.2, 0.2, 0.2))
  245. p.Name = "Head"
  246. local m = Instance.new("SpecialMesh")
  247. m.MeshType = "Brick"
  248. m.Scale = Vector3.new(3.5, 2.3, 3.5)
  249. m.Parent = p
  250. local h = Instance.new("Humanoid")
  251. h.Health = 0
  252. h.MaxHealth = 0
  253. h.Name = "asd"
  254. h.Parent = mo
  255. local nah = true
  256. mo.Parent = workspace
  257. local cf = CFrame.new(P) * CFrame.new(math.random(-Area*100, Area*100)/100, math.random(-Area*100, Area*100)/100, math.random(-Area*100, Area*100)/100)
  258. p.CFrame = cf
  259. Notime(function()
  260. Notime(function()
  261. for i = 0, 6, 0.03 do
  262. wait()
  263. p.CFrame = cf * CFrame.new(0, i, 0)
  264. end
  265. end)
  266. wait(1.5)
  267. for i = 0, 1, 0.05 do
  268. p.Transparency = i
  269. if nah then mo.Name = "" nah = false else mo.Name = "- "..D nah = true end
  270. wait()
  271. end
  272. mo:remove()
  273. end)
  274. end
  275.  
  276. mouse.Button1Down:connect(function()
  277. if db == false then
  278. if Ammo > 0 then
  279. Ammo = Ammo -1
  280. if pr == z1 then
  281. pr = z2
  282. else
  283. pr = z1
  284. end
  285. local cf = CFrame.new((pr.Position + mouse.Hit.p) / 2, mouse.Hit.p)
  286. local mag = (chr.Torso.Position - mouse.Hit.p).magnitude
  287. if (mag > 2048) then return end
  288. PlaySound(213603013, 1, pr, .3)
  289. local r = Instance.new("Part")
  290. r.BrickColor = BrickColor.Yellow()
  291. r.formFactor = "Custom"
  292. r.Transparency=.7
  293. r.Size = Vector3.new(0.2,0.2,mag)
  294. r.CFrame = cf
  295. r.Anchored = true
  296. r.CanCollide = false
  297. r.Parent = chr
  298. game:service'Debris':AddItem(r, .5)
  299. o1.Text = "Ammo: "..Ammo..'/'..MaxAmmo
  300. print(mouse.Target.Name)
  301. if mouse.Target.Parent:FindFirstChild('Humanoid') then
  302. if mouse.Target.Name == 'Head' or mouse.Target.Name == 'Handle' then
  303. Show_Damage(mouse.Target.Parent:FindFirstChild('Head').Position, 'HEADSHOT', 2)
  304. headshoot(mouse.Target.Parent:FindFirstChild('Torso'))
  305. print('Damage done: Headshot! (100)')
  306. mouse.Target.Parent:FindFirstChild('Head'):Destroy''
  307. elseif mouse.Target.Name == 'Left Leg' or mouse.Target.Name == 'Right Leg' then
  308. if mouse.Target.Parent:FindFirstChild('Humanoid') then
  309. local hum=mouse.Target.Parent:FindFirstChild('Humanoid')
  310. if hum then
  311. hum.Jump=true
  312. wait(.2)
  313. hum.PlatformStand=true
  314. end
  315. end
  316. else
  317. if mouse.Target.Parent:FindFirstChild('Humanoid') then
  318. local dmg=math.random(MinDamage, MaxDamage)
  319. mouse.Target.Parent:FindFirstChild('Humanoid').Health = mouse.Target.Parent:FindFirstChild('Humanoid').Health - dmg
  320. print('Damage done: '..dmg)
  321. Show_Damage(mouse.Target.Parent:FindFirstChild('Head').Position, dmg, 1.5)
  322. end
  323. end
  324. end
  325. else
  326. PlaySound(132464034, 1, pr, .2)
  327. print'No ammo!'
  328. end
  329. end
  330. end)
  331.  
  332.  
  333. mouse.KeyDown:connect(function(k)
  334. if k == 'r' then
  335. if Ammo < MaxAmmo then
  336. if Clip > 0 then
  337. PlaySound(138084889, 1, pr)
  338. if Clip >= MaxAmmo then
  339. local rload=MaxAmmo - Ammo
  340. Clip = Clip - rload
  341. Ammo = Ammo + rload
  342. print'reloaded!'
  343. o1.Text = "Ammo: "..Ammo..'/'..MaxAmmo
  344. o2.Text = "Clip: "..Clip
  345. elseif Clip <= MaxAmmo then
  346. local rload=Clip - Ammo
  347. if Ammo < rload then
  348. Ammo = rload
  349. else
  350. Ammo = Ammo - rload
  351. end
  352. o1.Text = "Ammo: "..Ammo..'/'..MaxAmmo
  353. o2.Text = "Clip: "..Clip
  354. end
  355. else
  356. print'No clip!'
  357. end
  358. end
  359. elseif k == string.char(48) then
  360. if chr:FindFirstChild('Humanoid') then
  361. chr:FindFirstChild('Humanoid').WalkSpeed = chr:FindFirstChild('Humanoid').WalkSpeed + 16
  362. end
  363. end
  364. end)
  365.  
  366. mouse.KeyUp:connect(function(k)
  367. if k == string.char(48) then
  368. if chr:FindFirstChild('Humanoid') then
  369. chr:FindFirstChild('Humanoid').WalkSpeed = chr:FindFirstChild('Humanoid').WalkSpeed - 16
  370. end
  371. end
  372. end)
  373.  
  374. lp.PlayerGui.DescendantRemoving:connect(function(obj)
  375. if obj.Name == 'AmmoGui' then
  376. makeAmmoGui()
  377. end
  378. end)
  379.  
  380.  
  381. local stepped = game:GetService'RunService'.RenderStepped
  382. local weld2 = Instance.new('Weld', trso)
  383. weld2.Part0 = trso
  384. weld2.Part1 = rarm
  385. weld2.C1 = CFrame.new(0,.5,0)
  386. local weld = Instance.new('Weld', trso)
  387. weld.Part0 = trso
  388. weld.Part1 = larm
  389. weld.C1 = CFrame.new(0,-.5,0)
  390.  
  391. while not stepped:wait() do
  392. local tCFrame = trso.CFrame
  393. local dir = (tCFrame*Vector3.new(-1.5, .5, 0) - mouse.Hit.p).unit
  394. local x = Vector3.new(0,1):Cross(dir)
  395. local z = x:Cross(dir)
  396. local dir = (tCFrame*Vector3.new( 1.5, .5, 0) - mouse.Hit.p).unit
  397. local x = Vector3.new(0,1):Cross(dir)
  398. local z = x:Cross(dir)
  399. weld2.C0 = tCFrame:inverse()*(CFrame.new(0,0,0, x.x, dir.x, z.x, x.y, dir.y, z.y, x.z, dir.z, z.z) + tCFrame*Vector3.new( 1.5, .5, 0) - dir/2)*weld2.C1
  400. weld.C0 = tCFrame:inverse()*(CFrame.new(0,0,0, x.x, dir.x, z.x, x.y, dir.y, z.y, x.z, dir.z, z.z) + tCFrame*Vector3.new(-1.5, .5, 0) - dir/2)*weld.C1
  401. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement