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