Advertisement
waconline

Tek 99

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