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