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