Advertisement
Wilkins1000

Untitled

Mar 12th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 35.61 KB | None | 0 0
  1. plr=game:service'Players'.LocalPlayer
  2. ch,char=plr.Character,plr.Character
  3. hum=ch.Humanoid
  4. tor,torso,rootpart,rj=ch.Torso,ch.Torso,ch.HumanoidRootPart,ch.HumanoidRootPart.RootJoint
  5. m,mouse=plr:GetMouse(),plr:GetMouse()
  6. cfn,ang,mr,int=CFrame.new,CFrame.Angles,math.rad,Instance.new
  7. bc=BrickColor.new
  8. head=ch.Head
  9. cam=workspace.CurrentCamera
  10.  
  11. rj.C0=cfn()
  12. rj.C1=cfn()
  13.  
  14. sheathed=false
  15. jammed=false
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27. local minimumsize = Vector3.new(0.7,0.7,0.7) --Minimumsize for a part to get divided,higher numbers = less detailed and bigger/less bricks
  28. local surface_between_splitted_parts = 'SmoothNoOutlines' --the surface between splitted parts
  29. --local fragmented = workspace:FindFirstChild("Fragmented")
  30. local fragmentable = workspace --all fragmentable objects should be stored in here
  31. local list = {}
  32. local brickcount = 0
  33. --local m = Instance.new("Hint",workspace)
  34. local storage = {}
  35. local fillup = 1000 --it constantly generates new parts until it reaches this number(hacky way to prevent lagspikes if there is a large explosion),change it to 0 if you don´t want it to generate (useless) parts.
  36. local maximumstorage = 2000 --it will recycle parts if the number of parts in the storage doesnt exceed this number
  37. local storage_position = Vector3.new(0,0,5000) --place them somewhere off the map
  38. local stored_partsize = Vector3.new(1,1,1) --make them small
  39. local parts_created_per_frame = 5 --number of parts being created per frame to fill up the storage
  40.  
  41.  
  42. function fragmentate(cframe,size,color,explosion_position,explosion_blastradius,backsurface,bottomsurface,frontsurface,leftsurface,rightsurface,topsurface,transparency,reflectance)
  43.     local xi = size.X >= minimumsize.X*(1+explosion_blastradius/16) and 2 or 1 --to reduce the lagg in large explosions we increase minimumsize based on the explosionradius...
  44.     local yi = size.Y >= minimumsize.Y*(1+explosion_blastradius/16) and 2 or 1
  45.     local zi = size.Z >= minimumsize.Z*(1+explosion_blastradius/16) and 2 or 1
  46.     if xi == 1 and yi == 1 and zi == 1 or (cframe.p-explosion_position).magnitude > size.magnitude/2 + explosion_blastradius then --don´t fragmentate parts, that are too small to fragmentate or too far away from the explosion
  47.         if xi == 1 and yi == 1 and zi == 1 then return end --optional
  48.         if #storage > 0 then
  49.             local p = storage[1]
  50.             p.BrickColor = color
  51.             p.Size = size
  52.             p.BackSurface = backsurface
  53.             p.BottomSurface = bottomsurface
  54.             p.FrontSurface = frontsurface
  55.             p.LeftSurface = leftsurface
  56.             p.RightSurface = rightsurface
  57.             p.TopSurface = topsurface
  58.             p.Transparency = transparency
  59.             p.CFrame = cframe
  60.             p.Reflectance = reflectance
  61.             table.remove(storage,1)
  62.         else
  63.             local p = Instance.new("Part",fragmentable)
  64.             p.BrickColor = color
  65.             p.FormFactor = "Custom"
  66.             p.Size = size
  67.             p.BackSurface = backsurface
  68.             p.BottomSurface = bottomsurface
  69.             p.FrontSurface = frontsurface
  70.             p.LeftSurface = leftsurface
  71.             p.RightSurface = rightsurface
  72.             p.TopSurface = topsurface
  73.             p.Transparency = transparency
  74.             if p.Transparency>0.285 then
  75.                 p.Anchored = false
  76.             else
  77.                 p.Anchored=true
  78.                 p.Material='Wood'
  79.             end
  80.             p.CFrame = cframe
  81.             p.Reflectance = reflectance
  82.         end
  83.         --p:MakeJoints()
  84. --      m.Text = m.Text+1
  85.         return --stop the function
  86.     end
  87.     local mody = math.random(-125,125)/1000 --some randomization
  88.     for y = 1,yi do
  89.         if math.random()> 0.5 then
  90.             local modx = math.random(-125,125)/1000
  91.             for x = 1,xi do
  92.                 local modz = math.random(-125,125)/1000
  93.                 for z = 1,zi do --offset = x/xi-0.75+modx)
  94.                     fragmentate(cframe*CFrame.new(size.X*(xi==1 and 0 or x/xi-0.75+modx),size.Y*(yi==1 and 0 or y/yi-0.75+mody),size.Z*(zi==1 and 0 or z/zi-0.75+modz)), --maths
  95.                     Vector3.new(xi == 2 and size.X*(1-2*math.abs(x/xi-0.75+modx)) or size.X,yi == 2 and size.Y*(1-2*math.abs(y/yi-0.75+mody)) or size.Y,
  96.                     zi == 2 and size.Z*(1-2*math.abs(z/zi-0.75+modz)) or size.Z or agent767_was_here),color,explosion_position,explosion_blastradius,
  97.                     z~=zi and surface_between_splitted_parts or backsurface,y==2 and surface_between_splitted_parts or bottomsurface,
  98.                     z==2 and surface_between_splitted_parts or frontsurface,x==2 and surface_between_splitted_parts or leftsurface,x~=xi and surface_between_splitted_parts or rightsurface,
  99.                     y~=yi and surface_between_splitted_parts or topsurface,transparency,reflectance)
  100.                 end
  101.                
  102.             end
  103.         else
  104.             local modz = math.random(-125,125)/1000
  105.             for z = 1,zi do
  106.                 local modx = math.random(-125,125)/1000
  107.                 for x = 1,xi do
  108.                     fragmentate(cframe*CFrame.new(size.X*(xi==1 and 0 or x/xi-0.75+modx),size.Y*(yi==1 and 0 or y/yi-0.75+mody),size.Z*(zi==1 and 0 or z/zi-0.75+modz)),
  109.                     Vector3.new(xi == 2 and size.X*(1-2*math.abs(x/xi-0.75+modx)) or size.X,yi == 2 and size.Y*(1-2*math.abs(y/yi-0.75+mody)) or size.Y,
  110.                     zi == 2 and size.Z*(1-2*math.abs(z/zi-0.75+modz)) or size.Z),color,explosion_position,explosion_blastradius,
  111.                     z~=zi and surface_between_splitted_parts or backsurface,y==2 and surface_between_splitted_parts or bottomsurface,
  112.                     z==2 and surface_between_splitted_parts or frontsurface,x==2 and surface_between_splitted_parts or leftsurface,x~=xi and surface_between_splitted_parts or rightsurface,
  113.                     y~=yi and surface_between_splitted_parts or topsurface,transparency,reflectance)
  114.                 end
  115.             end
  116.         end
  117.     end            
  118. end
  119.  
  120. function start_fragmentation(position,radius)
  121.     local search = Region3.new(position-Vector3.new(radius,radius,radius)*1.1,position+Vector3.new(radius,radius,radius)*1.1)
  122.     repeat
  123.     local finish = false
  124.     local parts = workspace:FindPartsInRegion3WithIgnoreList(search,list,100) --maximum number of parts that FindPartsInRegion3 can find is 100, so we have to do this to find them all
  125.     for i = 1,#parts do
  126.         table.insert(list,1,parts[i])
  127.     end
  128.     finish = true
  129.     until #parts < 100 and finish
  130.     print(#list)
  131.     local t = tick()
  132.     for i = 1,#list do
  133.         local p = list[i]
  134.         if p:IsDescendantOf(fragmentable) and p:GetMass()<3000 and p.Transparency>0.285 and p.Name~='Base' and p:IsDescendantOf(ch)==false then
  135.             fragmentate(p.CFrame,p.Size,p.BrickColor,position,radius,p.BackSurface,p.BottomSurface,p.FrontSurface,p.LeftSurface,p.RightSurface,p.TopSurface,p.Transparency,p.Reflectance)
  136.             if #storage < maximumstorage and p.Shape == "Block" then --recycle them
  137.                 p.Anchored = false
  138.                 p.FormFactor = "Custom"
  139.                 p.Size = stored_partsize
  140.                 p.Position = storage_position
  141.                 table.insert(storage,1,p)
  142.             else --storage is full
  143.                 p:Destroy()
  144.             end
  145. --          m.Text = m.Text-1
  146.         end
  147.         if p:IsDescendantOf(fragmentable) and p:GetMass()<53000 and p.Transparency<0.05 and p.Name~='Base' and tostring(p.Material)=='Enum.Material.Wood' and p:IsDescendantOf(ch)==false then
  148.             fragmentate(p.CFrame,p.Size,p.BrickColor,position,radius,p.BackSurface,p.BottomSurface,p.FrontSurface,p.LeftSurface,p.RightSurface,p.TopSurface,p.Transparency,p.Reflectance)
  149.             if #storage < maximumstorage and p.Shape == "Block" then --recycle them
  150.                 p.Anchored = true
  151.                 p.Material='Wood'
  152.                 p.FormFactor = "Custom"
  153.                 p.Size = stored_partsize
  154.                 p.Position = storage_position
  155.                 table.insert(storage,1,p)
  156.             else --storage is full
  157.                 p:Destroy()
  158.             end
  159. --          m.Text = m.Text-1
  160.         end
  161.     end
  162.     list = {}
  163. --  print(tick()-t)
  164. end
  165.  
  166. --[[
  167. spawn(function()
  168.     while wait() do --oh noes,a loop! So inefficient!
  169.         if #storage < fillup then
  170.             for i = 1, parts_created_per_frame do --creates parts to fill up the storage
  171.                 local p = Instance.new("Part",fragmentable)
  172.                 p.Anchored = false
  173.                 p.FormFactor = "Custom"
  174.                 p.Size = stored_partsize
  175.                 p.Position = storage_position
  176.                 table.insert(storage,1,p)
  177.             end
  178.         end
  179.     end
  180. end)
  181. ]]
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205. --local blankn=22416261
  206.  
  207. --172121567
  208.  
  209. crosshairs={
  210.     {38140824};
  211.     {38140833};
  212.     {38140839};
  213.     {38140843};
  214.     {38140852};
  215.     {38140910};
  216.     {38140915};
  217.     {38140923};
  218.     {38140928};
  219.     {38140931};
  220.     {38208259};
  221.     {38208275};
  222.     {38208284};
  223.     {38208303};
  224.     {38208310};
  225.     {38208325};
  226.     {38208330};
  227.     {38208352};
  228.     {38208359};
  229.     {38208377}
  230. }
  231.  
  232. bulletholes={
  233.     172274695;
  234.     172274721
  235. }
  236.  
  237. for _,v in pairs(crosshairs) do
  238.     game:service'ContentProvider':Preload('rbxassetid://' .. tostring(v[1]-1))
  239. end
  240.  
  241. currentIco=2
  242. switchIco=function(num)
  243.     if num<20 then
  244.     else
  245.         num=20
  246.     end
  247.     mouse.Icon='rbxassetid://' .. tostring(crosshairs[num][1]-1)
  248.     currentIco=num
  249. end
  250.  
  251. switchIco(currentIco)
  252.  
  253. heldDown=false
  254.  
  255. spreadint=1
  256. --[[Settings]]--
  257. recoil=false -- Set to true for added realism
  258. magCapacity=20 -- How much a magazine can hold at once
  259. magAmmo=20 -- How much ammo is in the mag
  260. crosshairSpread=5
  261. spread=1
  262. pAmmunition=true -- more damage if true
  263.  
  264.  
  265. jamRate=500 -- How often the gun jams(the more the less) (no less than 1)
  266.  
  267. primaryColor='Really black'
  268. secondaryColor='Really black'
  269.  
  270. slideReflectance=0.01
  271. slideMaterial='Plastic'
  272.  
  273. --[[Attachments]]--
  274.  
  275. silencer=true
  276. highCapMag=false -- High capacity magazine
  277. laser=true
  278. automatic=false
  279. grip=true
  280.  
  281.  
  282. getSound=function(id)
  283.     game:service'ContentProvider':Preload('rbxassetid'..tostring(id))
  284.     local s=int("Sound",ch.Head)
  285.     s.SoundId='rbxassetid://' .. tostring(id)
  286.     s.Volume=1
  287.     return s
  288. end
  289.  
  290. local fireSound=getSound(151997297--[[10209842]])
  291. fireSound.Pitch=1.3
  292. --1.8
  293.  
  294. local releaseSound=getSound(10209813)
  295. releaseSound.Pitch=4
  296.  
  297. local reloadSound=getSound(10209636)
  298. reloadSound.Pitch=3
  299.  
  300. local magazinelockSound=getSound(152206337)
  301. magazinelockSound.Pitch=1.4
  302.  
  303. local slideBackSound=getSound(152206263)
  304. slideBackSound.Pitch=2.5
  305.  
  306. local slideForwardSound=getSound(152206302)
  307. slideForwardSound.Pitch=2.5
  308.  
  309. local emptySound=getSound(2697295)
  310. emptySound.Pitch=5
  311.  
  312. local glassBreakSound=getSound(144884907)
  313.  
  314. local woodImpact=getSound(142082171)
  315.  
  316. local fleshImpact=getSound(144884872)
  317. fleshImpact.Pitch=1.7
  318.  
  319. if ch:findFirstChild("Tec-99") then
  320.     ch['Tec-99']:Destroy()
  321. end
  322.  
  323. local tube=int("Model",ch)
  324. tube.Name='Tec-99'
  325. local hopper=Instance.new('HopperBin',plr.Backpack)
  326. hopper.Name=tube.Name
  327. Weld = function(p0,p1,x,y,z,rx,ry,rz,par)--recommend to use this with my weld. use this function only with arm lockers.
  328.     p0.Position = p1.Position
  329.     local w = Instance.new('Motor',par or p0)
  330.     w.Part0 = p1
  331.     w.Part1 = p0
  332.     w.C0 = CFrame.new(x or 0,y or 0,z or 0)*CFrame.Angles(rx or 0,ry or 0,rz or 0)
  333.     w.MaxVelocity = .1
  334.     return w
  335. end
  336. function clerp(c1,c2,sp)
  337.     local R1,R2,R3 = c1:toEulerAnglesXYZ()
  338.     local R21,R22,R23 = c2:toEulerAnglesXYZ()
  339.     return CFrame.new(
  340.     c1.X + (c2.X-c1.X)*sp,
  341.     c1.Y + (c2.Y-c1.Y)*sp,
  342.     c1.Z + (c2.Z-c1.Z)*sp)*CFrame.Angles(
  343.     R1 + (R21-R1)*sp,
  344.     R2 + (R22-R2)*sp,
  345.     R3 + (R23-R3)*sp
  346.     )
  347. end
  348.  
  349. tweenTable={}
  350. Tween = function(Weld, Stop, Step,a)
  351. ypcall(function()
  352.     local func = function()
  353.         local Start = Weld.C1
  354.         local X1, Y1, Z1 = Start:toEulerAnglesXYZ()
  355.         local Stop = Stop
  356.         local X2, Y2, Z2 = Stop:toEulerAnglesXYZ()
  357.         if not Step then Step=0.1 end
  358.         table.insert(tweenTable,{th=0,Weld=Weld,Step=Step,Start=Start,X1=X1,Y1=Y1,Z1=Z1,Stop=Stop,X2=X2,Y2=Y2,Z2=Z2})
  359.     end
  360.         if a then coroutine.wrap(func)() else func() end
  361. end)
  362. end
  363. weld=function(p0,p1,c0)
  364.     local w=Instance.new("Weld",p0)
  365.     w.Part0=p0
  366.     w.Part1=p1
  367.     w.C0=c0
  368.     return w
  369. end
  370. cp=function(parent,color,size,anchored,cancollide)
  371.     local newp=Instance.new("Part",parent)
  372.     newp.TopSurface='SmoothNoOutlines'
  373.     newp.BottomSurface='SmoothNoOutlines'
  374.     newp.FrontSurface='SmoothNoOutlines'
  375.     newp.BackSurface='SmoothNoOutlines'
  376.     newp.RightSurface='SmoothNoOutlines'
  377.     newp.LeftSurface='SmoothNoOutlines'
  378.     newp.FormFactor="Custom"
  379.     newp.BrickColor=bc(color)
  380.     newp.Size=size
  381.     newp.Anchored=anchored
  382.     newp.CanCollide=cancollide
  383.     newp:BreakJoints()
  384.     return newp
  385. end
  386.  
  387. initializeJoints=function()
  388.     rabr = cp(tube,'White',Vector3.new(1,1,1),false,false) rabr.Transparency = 1 rabr.Name='Locker'
  389.     rabr.Position = torso.Position
  390.     rw = Weld(rabr,torso,1.5,.5,0,0,0,0) rw.Parent = tube rw.Name = 'rw'
  391.     w = Instance.new("Weld",tube)
  392.     w.Part0,w.Part1 = ch['Right Arm'],rabr
  393.     w.C1 = CFrame.new(0,-.5,0)
  394.     labr = cp(tube,'White',Vector3.new(1,1,1),false,false) labr.Transparency = 1 labr.Name='Locker'
  395.     labr.Position = torso.Position
  396.     lw = Weld(labr,torso,-1.5,.5,0,0,0,0) lw.Parent = tube lw.Name = 'lw'
  397.     ww = Instance.new("Weld",tube)
  398.     ww.Part0,ww.Part1 = ch['Left Arm'],labr
  399.     ww.C1 = CFrame.new(0,-.5,0)
  400. end
  401.  
  402. initializeJoints()
  403.  
  404. --[[ leg locks
  405. rabl = cp(tube,'White',Vector3.new(1,1,1),false,false) rabl.Transparency = 1 rabl.Name='Locker'
  406. rabl.Position = torso.Position
  407. rwl = Weld(rabl,torso,0.5,-1.5,0,0,0,0) rwl.Parent = tube rwl.Name = 'rwl'
  408. wl = Instance.new("Weld",tube)
  409. wl.Part0,wl.Part1 = ch['Right Leg'],rabl
  410. wl.C1 = CFrame.new(0,-.5,0)
  411. labl = cp(tube,'White',Vector3.new(1,1,1),false,false) labl.Transparency = 1 labl.Name='Locker'
  412. labl.Position = torso.Position
  413. lwl = Weld(labl,torso,-0.5,-1.5,0,0,0,0) lwl.Parent = tube lwl.Name = 'lwl'
  414. wwl = Instance.new("Weld",tube)
  415. wwl.Part0,wwl.Part1 = ch['Left Leg'],labl
  416. wwl.C1 = CFrame.new(0,-.5,0)
  417. ]]
  418. --weld(ch['HumanoidRootPart'],torso,cfn())
  419.  
  420.  
  421. local counter=Instance.new('ScreenGui',plr.PlayerGui)
  422. local frame=Instance.new('Frame',counter)
  423. frame.Size=UDim2.new(0.25,0,0.3,0)
  424.  
  425. frame.Position=UDim2.new(0.1,0,0.4,0)
  426. frame.BackgroundTransparency=1
  427.  
  428. local ammocounter=Instance.new('TextLabel',frame)
  429. ammocounter.Size=UDim2.new(1,0,0.3,0)
  430. ammocounter.Position=UDim2.new(0,0,0.2,0)
  431. ammocounter.BackgroundTransparency=1
  432. ammocounter.TextColor3=BrickColor.new('White').Color
  433. ammocounter.Font='SourceSansBold'
  434. ammocounter.FontSize='Size18'
  435. ammocounter.Text=''
  436. ammocounter.TextXAlignment='Left'
  437.  
  438.  
  439. local bg = Instance.new("BodyGyro",rootpart)
  440. bg.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
  441. bg.P = 10000
  442. bg.D = 100
  443.  
  444.  
  445. cyl=function(prt)
  446.     local c=int("CylinderMesh",prt)
  447.     return c
  448. end
  449. blo=function(prt)
  450.     local c=int("BlockMesh",prt)
  451.     return c
  452. end
  453.  
  454. if laser then
  455.     aLaser=cp(tube,'Really red',Vector3.new(0.2,0.2,0.2))
  456.     aLaser.Transparency=1
  457.     cyl(aLaser).Scale=Vector3.new(0.25,1,0.25)
  458.     aLaser.Anchored=true
  459. end
  460.  
  461. local handle=cp(tube,primaryColor,Vector3.new(0.2,0.6,0.3))
  462. blo(handle).Scale=Vector3.new(1.15,0.9,1)
  463. local mw=weld(ch['Right Arm'],handle,cfn(-0.4,-1,-0.19)*ang(mr(-101.5),0,0)*cfn()*ang(0,mr(-30),mr(-5)))
  464.  
  465. local framepiece1=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.9))
  466. blo(framepiece1).Scale=Vector3.new(1.15,0.5,1)
  467. weld(handle,framepiece1,cfn(0,0.354,-0.3)*ang(mr(11.5),0,0))
  468.  
  469. local barrel=cp(tube,'Medium stone grey',Vector3.new(0.2,0.2,0.2))
  470. cyl(barrel).Scale=Vector3.new(0.7,1.2,0.7)
  471. weld(framepiece1,barrel,cfn(0,0.15,-0.1)*ang(mr(-90),0,0))
  472.    
  473. local sbarrel=cp(tube,'Really black',Vector3.new(0.2,0.3,0.2))
  474. cyl(sbarrel).Scale=Vector3.new(0.7,1.5,0.7)
  475. weld(barrel,sbarrel,cfn(0,0.35,0))
  476. local hole=cp(tube,'White',Vector3.new(0.2,0.2,0.2))
  477. hole.Transparency=1
  478. weld(sbarrel,hole,cfn(0,0.2,0))
  479. local flash=int('PointLight',hole)
  480. flash.Enabled=false
  481. flash.Range=10
  482. flash.Color=BrickColor.new('Neon orange').Color
  483.  
  484.    
  485. local slide1=cp(tube,secondaryColor,Vector3.new(0.2,0.2,0.4))
  486. slide1.CanCollide=false
  487. blo(slide1).Scale=Vector3.new(0.7,1,1.1)
  488. slideweld1=weld(framepiece1,slide1,cfn(0,0.15,0.23))
  489. slide1.Reflectance=slideReflectance
  490. slide1.Material=slideMaterial
  491.  
  492. local slide2=cp(tube,secondaryColor,Vector3.new(0.2,0.2,0.4))
  493. slide2.CanCollide=false
  494. blo(slide2).Scale=Vector3.new(0.7,1,1.1)
  495. slideweld2=weld(slide1,slide2,cfn(0,0,-0.666))
  496. slide2.Reflectance=slideReflectance
  497. slide2.Material=slideMaterial
  498.    
  499. local slideside1=cp(tube,secondaryColor,Vector3.new(0.2,0.2,1.1))
  500. slideside1.CanCollide=true
  501. blo(slideside1).Scale=Vector3.new(0.25,1,1)
  502. weld(slide1,slideside1,cfn(-0.09,0,-0.335))
  503. slideside1.Reflectance=slideReflectance
  504. slideside1.Material=slideMaterial
  505.  
  506. local slideside2=cp(tube,secondaryColor, Vector3.new(0.2,0.2,0.4))
  507. slideside2.CanCollide=true
  508. blo(slideside2).Scale=Vector3.new(0.25,1,1.1)
  509. weld(slide1,slideside2,cfn(0.09,0,0))
  510. slideside2.Reflectance=slideReflectance
  511. slideside2.Material=slideMaterial
  512.  
  513. local slideside3=cp(tube,secondaryColor, Vector3.new(0.2,0.2,0.3))
  514. slideside3.CanCollide=true
  515. blo(slideside3).Scale=Vector3.new(0.25,0.6,0.78)
  516. weld(slideside2,slideside3,cfn(0,-0.04,-0.335))
  517. slideside3.Reflectance=slideReflectance
  518. slideside3.Material=slideMaterial
  519.  
  520. local slideside4=cp(tube,secondaryColor, Vector3.new(0.2,0.2,0.4))
  521. blo(slideside4).Scale=Vector3.new(0.25,1,1.1)
  522. weld(slide2,slideside4,cfn(0.09,0,0))
  523. slideside4.Reflectance=slideReflectance
  524. slideside4.Material=slideMaterial
  525.  
  526. local mgs=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  527. blo(mgs).Scale=Vector3.new(1.15,0.425,0.245)
  528. weld(handle,mgs,cfn(0,-0.3,0.125))
  529.  
  530. --[[Trigger]]--
  531. local tp1=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  532. blo(tp1).Scale=Vector3.new(0.6,0.1,0.8)
  533. weld(framepiece1,tp1,cfn(0,-0.22,0.13))
  534.  
  535. local tp2=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  536. blo(tp2).Scale=Vector3.new(0.6,0.1,1.19)
  537. weld(framepiece1,tp2,cfn(0,-0.14,-0.0265)*ang(mr(45),0,0))
  538.  
  539. local trigger1=cp(tube,'Really black',Vector3.new(0.2,0.2,0.2))
  540. blo(trigger1).Scale=Vector3.new(0.3,0.4,0.16)
  541. weld(framepiece1,trigger1,cfn(0,-0.07,0.09))
  542.    
  543. local trigger2=cp(tube,'Really black',Vector3.new(0.2,0.2,0.2))
  544. blo(trigger2).Scale=Vector3.new(0.3,0.3,0.16)
  545. weld(trigger1,trigger2,cfn(0,-0.06,-0.015)*ang(mr(30),0,0))
  546.    
  547.    
  548. --[[Magazine]]--
  549.  
  550. local magh=cp(tube,'Really black',Vector3.new(0.2,0.5,0.2))
  551. blo(magh).Scale=Vector3.new(0.6,1,1)
  552. local magweld=weld(handle,magh,cfn(0,-0.025,0))
  553.    
  554. local bottom=cp(tube,'Really black',Vector3.new(0.2,0.2,0.3))
  555. blo(bottom).Scale=Vector3.new(1.15,0.385,0.8)
  556. bottomweld=weld(magh,bottom,cfn(0,-0.28,-0.015))
  557.    
  558. if highCapMag then
  559.     magweld:Destroy()    
  560.     magh.Size=Vector3.new(0.2,0.7,0.2)
  561.     magweld=weld(handle,magh,cfn(0,-0.125,0))
  562.     bottomweld:Destroy()
  563.     bottomweld=weld(magh,bottom,cfn(0,-0.38,-0.015))
  564.     magCapacity=magCapacity+23
  565.     magAmmo=magAmmo+23
  566. end
  567.    
  568. --[[Sights]]--
  569. local backsight1=cp(tube,'Black',Vector3.new(0.2,0.2,0.2))
  570. blo(backsight1).Scale=Vector3.new(0.3,0.3,0.3)
  571. weld(slide1,backsight1,cfn(0.06,0.1,0.13))
  572. local backsight2=cp(tube,'Black',Vector3.new(0.2,0.2,0.2))
  573. blo(backsight2).Scale=Vector3.new(0.3,0.3,0.3)
  574. weld(slide1,backsight2,cfn(-0.06,0.1,0.13))
  575.  
  576. local frontsight=cp(tube,'Black',Vector3.new(0.2,0.2,0.2))
  577. blo(frontsight).Scale=Vector3.new(0.3,0.3,0.3)
  578. weld(slide1,frontsight,cfn(0,0.1,-0.85))
  579.    
  580. local dot1=cp(tube,'Lime green',Vector3.new(0.2,0.2,0.2))
  581. cyl(dot1).Scale=Vector3.new(0.1,0.31,0.1)
  582. weld(backsight1,dot1,cfn(0,0.014,0)*ang(mr(-90),0,0))
  583.    
  584. local dot2=cp(tube,'Lime green',Vector3.new(0.2,0.2,0.2))
  585. cyl(dot2).Scale=Vector3.new(0.1,0.31,0.1)
  586. weld(backsight2,dot2,cfn(0,0.014,0)*ang(mr(-90),0,0))
  587.    
  588. local dot3=cp(tube,'Lime green',Vector3.new(0.2,0.2,0.2))
  589. cyl(dot3).Scale=Vector3.new(0.1,0.31,0.1)
  590. weld(frontsight,dot3,cfn(0,0.014,0)*ang(mr(-90),0,0))
  591.  
  592. local ba=cp(tube,secondaryColor,Vector3.new(0.2,0.2,0.2))
  593. blo(ba).Scale=Vector3.new(1.15,0.5,1)
  594. weld(framepiece1,ba,cfn(0,0,-0.55))
  595. ba.Reflectance=slideReflectance
  596. ba.Material=slideMaterial
  597.  
  598. local weirdholethatpistolshave=cp(tube,'Really black', Vector3.new(0.2,0.2,0.2))
  599. cyl(weirdholethatpistolshave).Scale=Vector3.new(0.4,1.01,0.4)
  600. weld(ba,weirdholethatpistolshave,cfn(0,0,0)*ang(mr(-90),0,0))
  601.  
  602. --[[Tactical Rails]]--
  603.  
  604. local r1=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  605. blo(r1).Scale=Vector3.new(1.15,0.2,0.25)
  606. weld(framepiece1,r1,cfn(0,-0.05,-0.17))
  607.  
  608. local r2=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  609. blo(r2).Scale=Vector3.new(1.15,0.2,0.25)
  610. weld(framepiece1,r2,cfn(0,-0.05,-0.27))
  611.    
  612. local r3=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2))
  613. blo(r3).Scale=Vector3.new(1.15,0.2,0.25)
  614. weld(framepiece1,r3,cfn(0,-0.05,-0.37))
  615.    
  616. if laser then
  617.     local base=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.3))
  618.     blo(base).Scale=Vector3.new(1.15,1,1)
  619.     weld(r2,base,cfn(0,-0.05,0))
  620.     basehole=cp(tube,'White',Vector3.new(0.2,0.2,0.2))
  621.     cyl(basehole).Scale=Vector3.new(0.4,0.4,0.4)
  622.     weld(base,basehole,cfn(0,0,-0.13)*ang(mr(-90),0,0))
  623. end
  624.  
  625. if silencer then
  626.     local sil=cp(tube,'Really black',Vector3.new(0.2,0.3,0.2))
  627.     fireSound.SoundId='rbxassetid://153230595'
  628.     fireSound.Pitch=1
  629.     cyl(sil).Scale=Vector3.new(0.94,1.8,0.94)
  630.     weld(hole,sil,cfn(0,0.29,0))
  631. end
  632.  
  633. if grip then
  634.     local base=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.3))
  635.     blo(base).Scale=Vector3.new(1.15,1,1)
  636.     weld(r2,base,cfn(0,-0.05,0))
  637.     local hd=cp(tube,primaryColor,Vector3.new(0.2,0.6,0.2))
  638.     cyl(hd)
  639.     weld(base,hd,cfn(0,-0.3,0))
  640.     crosshairSpread=3
  641.     spreadint=spreadint-0.3
  642. end
  643.  
  644. --[[Test Functions]]--
  645.  
  646. local debounce=false
  647. local out=false
  648. local bs=false
  649. cockSlide=function() -- hahaha yes i know
  650.     slideBackSound:Play()
  651.     if magAmmo<1 and out==true and bs==false then
  652.         wait()
  653.         slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  654.     else
  655.         for i=1,2 do
  656.             wait()
  657.             slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  658.         end
  659.     end
  660.     local ajar=false
  661.     if magAmmo==1 then
  662.         ajar=true
  663.     end
  664.     if magAmmo>0 then
  665.         createShell()
  666.         --magAmmo=magAmmo-1
  667.         ammocounter.Text=''
  668.         for i=1,magAmmo do
  669.            ammocounter.Text=ammocounter.Text .. 'I'
  670.         end
  671.     end
  672.     wait(0.15)
  673.     slideForwardSound:Play()
  674.     for i=1,2 do
  675.         wait()
  676.         slideweld1.C0=slideweld1.C0*cfn(0,0,-0.22)
  677.     end
  678.     if ajar==true then
  679.         out=true
  680.         slideweld1.C0=cfn(0,0.15,0.23)
  681.         slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  682.     end
  683. end
  684.  
  685. --fx
  686. local firefx=cp(tube,'Neon orange',Vector3.new(0.7,1.1,0.7))
  687. firefx.Transparency=1
  688. local mesh=Instance.new('SpecialMesh',firefx)
  689. mesh.MeshType='Sphere'
  690. firefx.Material='Neon'
  691. weld(hole,firefx,cfn(0,1,0))
  692.  
  693. local smokefx=Instance.new('Smoke',hole)
  694. smokefx.Enabled=false
  695. barrel.CanCollide=true
  696.  
  697.  
  698.  
  699.  
  700. local oc = oc or function(...) return ... end
  701.  
  702. function ragJoint(hit,r,d)
  703.     Spawn(oc(function()
  704.     d = d or 0
  705.     local rpar,r0,r1 = r.Parent,r.Part0,r.Part1
  706.     if d > 0 then wait(d) end
  707.     local p = hit:Clone()
  708.     p:BreakJoints()
  709.     p:ClearAllChildren()
  710.     p.FormFactor = "Custom"
  711.     p.Size = p.Size/2
  712.     p.Transparency = 1
  713.     p.CanCollide = true
  714.     p.Name = "Colliduh"
  715.     p.Parent = hit
  716.     local w = Instance.new("Weld",p)
  717.     w.Part0 = hit
  718.     w.Part1 = p
  719.     w.C0 = CFrame.new(0,-p.Size.Y/2,0)
  720.     local rot = Instance.new("Rotate",rpar)
  721.     rot.Name = r.Name
  722.     rot.Part0 = r0
  723.     rot.Part1 = r1
  724.     rot.C0 = r.C0
  725.     rot.C1 = r.C1
  726.     r0.Velocity = Vector3.new()
  727.     r1.Velocity = Vector3.new()
  728.     r:Destroy()
  729.     end))
  730. end
  731.  
  732.  
  733. createShell=function()
  734.     local shell=cp(tube,'Deep orange',Vector3.new(0.2,0.3,0.2))
  735.     shell.CanCollide=true
  736.     shell.Reflectance=0.3
  737.     cyl(shell)
  738.     shell.CFrame=barrel.CFrame*ang(mr(-90),0,0)
  739.     magAmmo=magAmmo-1
  740.     ammocounter.Text=''
  741.     for i=1,magAmmo do
  742.         ammocounter.Text=ammocounter.Text .. 'I'
  743.     end
  744.     game.Debris:AddItem(shell,3)
  745. end
  746.  
  747. reloadPistol=function()
  748.     local current=magAmmo
  749.     Tween(lw,cfn())
  750.     Tween(rw,cfn()*ang(mr(-102),0,0))
  751.     wait(0.4)
  752.     releaseSound:Play()
  753.     bottom.Transparency=1
  754.     magh.Transparency=1
  755.     local mag1=magh:clone()
  756.     mag1.Transparency=0
  757.     mag1.Weld:Destroy''
  758.     local mag2=bottom:clone()
  759.     mag2.Transparency=0
  760.     mag1:BreakJoints''
  761.     mag2:BreakJoints''
  762.     local bm1=mag1:clone()
  763.     local bm2=mag2:clone()
  764.     mag1.Parent=tube
  765.     mag2.Parent=tube
  766.     mag1.CFrame=magh.CFrame
  767.     weld(mag1,mag2,cfn(0,-0.28,-0.015))
  768.     magAmmo=0
  769.     ammocounter.Text=''
  770.     for i=1,magAmmo do
  771.         ammocounter.Text=ammocounter.Text .. 'I'
  772.     end
  773.     wait()
  774.     mag1.CanCollide=true
  775.     mag2.CanCollide=true
  776.     game.Debris:AddItem(mag1,2)
  777.     game.Debris:AddItem(mag2,2)
  778.     wait(0.1)
  779.     Tween(lw,cfn()*ang(mr(25),0,0))
  780.     bm1.Parent=tube
  781.     bm2.Parent=tube
  782.     weld(bm1,bm2,cfn(0,-0.28,-0.015))
  783.     local fa=weld(ch['Left Arm'],bm1,cfn(0,-1.1,0)*ang(mr(-90),0,0))
  784.     wait(0.1)
  785.     Tween(lw,cfn(0,1.4,0)*ang(mr(-109),mr(60),mr(10)),0.07)
  786.     wait(0.25)
  787.     magazinelockSound:Play()
  788.     wait()
  789.    -- reloadSound:Play()
  790.     fa:Destroy''
  791.     bm1:Destroy''
  792.     bm2:Destroy''
  793.     bottom.Transparency=0
  794.     magh.Transparency=0
  795.     local totalcap=0
  796.     if current<1 then --none in chamber reload
  797.         --slideweld1.C0=cfn(0,0,0.45)
  798.         Tween(rw,cfn(0,0.7,0)*ang(mr(-90),mr(-30),0))
  799.         Tween(lw,cfn(0,0.7,0)*ang(mr(-115),mr(35),0))
  800.         wait(0.1)
  801.         spawn(function()
  802.             cockSlide()
  803.         end)
  804.         Tween(lw,cfn(0,0.7,0)*ang(mr(-115),mr(55),0))
  805.         wait(0.3)
  806.         totalcap=magCapacity
  807.     else
  808.         totalcap=magCapacity+1
  809.     end
  810.     magAmmo=totalcap
  811.     out=false
  812.     ammocounter.Text=''
  813.     for i=1,magAmmo do
  814.         ammocounter.Text=ammocounter.Text .. 'I'
  815.     end
  816.     restorePosition()
  817. end
  818.  
  819. firePistol=function()
  820.     switchIco(currentIco+crosshairSpread)
  821.     if not jammed and not out then
  822.         spread=spread+spreadint
  823.     end
  824.     print(spread)
  825.     fireSound.Pitch=math.random(math.random(fireSound.Pitch-0.2,fireSound.Pitch-0.1),math.random(fireSound.Pitch,fireSound.Pitch+0.1))
  826.     if magAmmo>0 and jammed==false then
  827.         local ajar=false
  828.         if magAmmo==1 then
  829.             ajar=true
  830.         end
  831.         user=ch
  832.         local ray = Ray.new(hole.CFrame.p, ((m.Hit.p+Vector3.new(math.random(-spread,spread)/6.35,math.random(-spread,spread)/6.35,math.random(-spread,spread)/6.35) )- hole.CFrame.p).unit*300)
  833.         local hit, position = game.Workspace:FindPartOnRay(ray, user)
  834.         if hit then
  835.             if hit.Transparency>0.285 and hit:GetMass()<3000 and hit.Parent.className~='Hat' then
  836.                 local temps=glassBreakSound:clone()
  837.                 temps.Parent=hit
  838.                 temps.Pitch=math.random(math.random(temps.Pitch-0.2,temps.Pitch-0.1),math.random(temps.Pitch,temps.Pitch+0.1))
  839.                 temps:Play''
  840.                 start_fragmentation(position,.25)
  841.             end
  842.             if tostring(hit.Material)=='Enum.Material.Wood' and hit.Transparency<0.05 then
  843.                 local temps=woodImpact:clone()
  844.                 temps.Volume=1
  845.                 temps.Pitch=math.random(math.random(temps.Pitch-0.2,temps.Pitch-0.1),math.random(temps.Pitch,temps.Pitch+0.1))
  846.                 temps.Parent=hit
  847.                 temps:Play''
  848.                 start_fragmentation(position,.15)
  849.             end
  850.             ypcall(function()
  851.                 if hit and hit.Parent and hit.Parent:findFirstChild'Humanoid' then
  852.                     local temps=fleshImpact:clone()
  853.                     temps.Parent=hit
  854.                     temps:Play()
  855.                     if hit.Name~='Head' then
  856.                         if pAmmunition==true then
  857.                             hit.Parent.Humanoid:TakeDamage(math.random(30,65))
  858.                         else
  859.                             hit.Parent.Humanoid:TakeDamage(math.random(10,24))
  860.                         end
  861.                         local guy=hit.Parent
  862.                         if guy.Name~='TheDarkRevenant' then
  863.                             for i,v in pairs(guy:GetChildren()) do
  864.                                 if v.className=='Hat' then
  865.                                     v.Handle:BreakJoints()
  866.                                 end
  867.                                 local r = guy.Torso:FindFirstChild(v.Name:gsub("Arm","Shoulder"):gsub("Leg","Hip"))
  868.                                 if v:IsA("BasePart") and r then
  869.                                     ragJoint(v,r,.1)
  870.                                 elseif v:IsA("Humanoid") then
  871.                                     spawn(function()
  872.                                         wait(0.5)
  873.                                         v.PlatformStand = true
  874.                                         v.Changed:connect(function()
  875.                                             v.PlatformStand = true
  876.                                         end)
  877.                                     end)
  878.                                 end
  879.                             end
  880.                         end
  881.                    
  882.                     else
  883.                         if hit.Parent.Name~='TheDarkRevenant' then
  884.                             hit.Parent:BreakJoints()
  885.                         end
  886.                     end
  887.                 end
  888.  
  889.             if hit.Parent.className=='Hat' then
  890.                 hit.CanCollide=true
  891.                 hit:BreakJoints()
  892.                 hit.Velocity=m.Hit.p*5
  893.             end
  894.         end)
  895.         end
  896.         if m.Target then
  897.             local p = Instance.new("Part")
  898.             p.formFactor = "Custom"
  899.             p.Size = Vector3.new(0.5,0.5,0.5)
  900.             p.Transparency = 1
  901.             p.CanCollide = false
  902.             p.Locked = true
  903.             p.CFrame = CFrame.new(position.x,position.y,position.z)--mouse.Target.CFrame+(mouse.Hit.p-mouse.Target.Position)
  904.             local w = Instance.new("Weld")
  905.             w.Part0 = mouse.Target
  906.             w.Part1 = p
  907.             w.C0 = mouse.Target.CFrame:inverse()
  908.             w.C1 = p.CFrame:inverse()
  909.             w.Parent = p
  910.             local d = Instance.new("Decal")
  911.             d.Parent = p
  912.             d.Face = mouse.TargetSurface
  913.             d.Texture = 'rbxassetid://' .. tostring(bulletholes[math.random(#bulletholes)]-2)
  914.             p.Parent = tube
  915.             game.Debris:AddItem(p,6)
  916.         end
  917.         if recoil==true then
  918.             cam:SetRoll(math.random(-2,2))
  919.             cam:TiltUnits(0.501)
  920.         end
  921.         local th=cp(tube,"Really black",Vector3.new(1,1,1))
  922.         th.CanCollide=false
  923.         th.Anchored=true
  924.         th.CFrame=CFrame.new(position.x,position.y,position.z)
  925.         local spm=Instance.new('SpecialMesh',th)
  926.         spm.MeshType='Sphere'
  927.         spm.Scale=Vector3.new(0.05,0.05,0.05)
  928.         spawn(function()
  929.             for i=1,5 do
  930.                 wait()
  931.                 spm.Scale=spm.Scale+Vector3.new(0.16,0.16,0.16)
  932.                 th.Transparency=th.Transparency+0.2
  933.             end
  934.             th:Destroy()
  935.         end)
  936.         fireSound:Play()
  937.         spawn(function()
  938.             firefx.Transparency=0
  939.             wait()
  940.             firefx.Transparency=1
  941.         end)
  942.         spawn(function()
  943.             flash.Enabled=true
  944.             for i=1,2 do
  945.                 wait()
  946.                 slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  947.             end
  948.             flash.Enabled=false
  949.             createShell()
  950.             for i=1,2 do
  951.                 wait()
  952.                 slideweld1.C0=slideweld1.C0*cfn(0,0,-0.22)
  953.             end
  954.             slideweld1.C0=cfn(0,0.15,0.23)
  955.             if ajar==true then
  956.                 out=true
  957.                 slideweld1.C0=cfn(0,0.15,0.23)
  958.                 slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  959.             end
  960.         end)
  961.         ammocounter.Text=''
  962.         for i=1,magAmmo do
  963.            ammocounter.Text=ammocounter.Text .. 'I'
  964.         end
  965.         wait()
  966.         Tween(rw,cfn(0,0.7,0)*ang(mr(-100),mr(-30),0),0.62)
  967.         if not grip then
  968.             Tween(lw,cfn(0,0.7,0)*ang(mr(-100),mr(30),0),0.62)
  969.         else
  970.             Tween(lw,cfn(0,1.3,0)*ang(mr(-100),mr(30),0),0.62)
  971.         end
  972.         wait(0.065)
  973.         restorePosition(0.3)
  974.     else
  975.         if magAmmo<1 then
  976.             slideweld1.C0=cfn(0,0.15,0.23)
  977.             slideweld1.C0=slideweld1.C0*cfn(0,0,0.22)
  978.         end
  979.         emptySound:Play()
  980.     end
  981.     if math.random(jamRate)==jamRate and magAmmo>0 then
  982.         jammed=true
  983.     end
  984. end
  985.  
  986. debounced=function()
  987.     if sheathed==false and debounce==false then
  988.         return true
  989.     end
  990. end
  991.  
  992. mouse.Button1Down:connect(function()
  993.     if debounced() then
  994.         if automatic==false then
  995.             debounce=true
  996.             firePistol()
  997.             debounce=false
  998.         else
  999.          heldDown=true
  1000.             firePistol()
  1001.         end
  1002.     end
  1003. end)
  1004.  
  1005. mouse.Button1Up:connect(function()
  1006.     heldDown=false
  1007. end)
  1008.  
  1009. sheathGun=function()
  1010.     ammocounter.Visible=false
  1011.     if laser then
  1012.         laserEnabled=false
  1013.         aLaser.Transparency=1
  1014.     end
  1015.     Tween(rw,cfn())
  1016.     Tween(lw,cfn())
  1017.     wait(0.1)
  1018.     mw:Destroy''
  1019.     mw=nil
  1020.     mw=weld(tor,handle,cfn(1.11,-1.09,0)*ang(mr(-111.5),0,0))
  1021.     labr:Destroy()
  1022.     rabr:Destroy()
  1023.     bg.maxTorque=Vector3.new()
  1024.     sheathed=true
  1025. end
  1026.  
  1027. unsheathGun=function()
  1028.     ammocounter.Visible=true
  1029.     mw:Destroy''
  1030.     mw=nil
  1031.     initializeJoints()
  1032.     mw=weld(ch['Right Arm'],handle,cfn(-0.4,-1,-0.19)*ang(mr(-101.5),0,0)*cfn()*ang(0,mr(-30),mr(-5)))
  1033.     restorePosition()
  1034.     bg.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
  1035.     sheathed=false
  1036. end
  1037.  
  1038. laserEnabled=false
  1039.  
  1040. mouse.KeyDown:connect(function(key)
  1041.     if key=='r' and debounced() then
  1042.         debounce=true
  1043.         reloadPistol()
  1044.         debounce=false
  1045.     elseif key=='f' and debounced() then
  1046.         debounce=true
  1047.         bs=true
  1048.         Tween(rw,cfn(0,0.7,0)*ang(mr(-90),mr(-30),0))
  1049.         Tween(lw,cfn(0,0.7,0)*ang(mr(-115),mr(35),0))
  1050.         wait(0.1)
  1051.         spawn(function()
  1052.             cockSlide()
  1053.         end)
  1054.         Tween(lw,cfn(0,0.7,0)*ang(mr(-115),mr(55),0))
  1055.         wait(0.3)
  1056.         jammed=false
  1057.         restorePosition()
  1058.         bs=false
  1059.         debounce=false
  1060.     elseif key=='l' and debounced() then
  1061.         if not laserEnabled then
  1062.             laserEnabled=true
  1063.             aLaser.Transparency=0.35
  1064.         else
  1065.             laserEnabled=false
  1066.             aLaser.Transparency=1
  1067.         end
  1068.     end
  1069. end)
  1070.  
  1071. restorePosition=function(speed)
  1072.     if not grip then
  1073.         Tween(rw,cfn(0,0.7,0)*ang(mr(-90),mr(-30),0),speed)
  1074.         Tween(lw,cfn(0,0.7,0)*ang(mr(-90),mr(30),0),speed)
  1075.     else
  1076.         Tween(rw,cfn(0,0.7,0)*ang(mr(-90),mr(-30),0),speed)
  1077.         Tween(lw,cfn(0,1.3,0)*ang(mr(-90),mr(30),0),speed)
  1078.     end
  1079. end
  1080.  
  1081. hopper.Selected:connect(function()
  1082.     unsheathGun()
  1083. end)
  1084.  
  1085. hopper.Deselected:connect(function()
  1086.     sheathGun()
  1087. end)
  1088.  
  1089. game:service'RunService'.RenderStepped:connect(function()
  1090.     bg.cframe = CFrame.new(rootpart.Position,mouse.Hit.p*Vector3.new(1,0,1)+rootpart.Position*Vector3.new(0,1,0))
  1091.     if laserEnabled==true then
  1092.         local user=ch
  1093.         local ray = Ray.new(hole.CFrame.p, (m.Hit.p - hole.CFrame.p).unit*300)
  1094.         local hit, position = game.Workspace:FindPartOnRay(ray, user)
  1095.         local distance = (position - basehole.CFrame.p).magnitude
  1096.         aLaser.Size=Vector3.new(0.2,distance,0.2)
  1097.         aLaser.CFrame=CFrame.new(position, basehole.CFrame.p) * CFrame.new(0, 0, -distance/2) * ang(mr(-90),0,0)
  1098.     end
  1099.     for _,v in pairs(tweenTable) do
  1100.         if v.Weld.C1==v.Stop then
  1101.             table.remove(tweenTable,_)
  1102.         else
  1103.             if v.th<0.9 then
  1104.                 v.th=v.th+v.Step
  1105.                 i=v.th
  1106.                 v.Weld.C1 = CFrame.new( (v.Start.p.X * (1 - i)) + (v.Stop.p.X * i),
  1107.                 (v.Start.p.Y * (1 - i)) + (v.Stop.p.Y * i),
  1108.                 (v.Start.p.Z * (1 - i)) + (v.Stop.p.Z * i)) * CFrame.fromEulerAnglesXYZ(
  1109.                 (v.X1 * (1 - i)) + (v.X2 * i), (v.Y1 * (1 - i)) + (v.Y2 * i),
  1110.                 (v.Z1 * (1 - i)) + (v.Z2 * i) )
  1111.             else
  1112.                 v.Weld.C1 = v.Stop
  1113.             end
  1114.         end
  1115.     end
  1116. end)
  1117. for i=1,magAmmo do
  1118.    ammocounter.Text=ammocounter.Text .. 'I'
  1119. end
  1120.  
  1121. sheathGun()
  1122.  
  1123. spawn(function()
  1124.     while wait(0.07) do
  1125.         if heldDown==true then
  1126.             spawn(function()
  1127.                 firePistol()
  1128.             end)
  1129.         end
  1130.     end
  1131. end)
  1132. m.TargetFilter=tube
  1133.  
  1134. while wait(0.03) do
  1135.     if spread>1 then
  1136.        spread=spread-spreadint/4
  1137.     end
  1138.     if spread<1 then
  1139.        spread=1
  1140.     end
  1141.     if currentIco>2 then
  1142.        switchIco(currentIco-1)
  1143.     end
  1144. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement