Advertisement
Ephkyr

Tec NEIN

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