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