· 8 years ago · Dec 09, 2017, 08:24 PM
1
2--have fun xddkfds
3function sandbox(var,func)
4 local env = getfenv(func)
5 local newenv = setmetatable({},{
6 __index = function(self,k)
7 if k=="script" then
8 return var
9 else
10 return env[k]
11 end
12 end,
13 })
14 setfenv(func,newenv)
15 return func
16end
17cors = {}
18mas = Instance.new("Model",game:GetService("Lighting"))
19Tool0 = Instance.new("Tool")
20IntValue1 = Instance.new("IntValue")
21IntValue2 = Instance.new("IntValue")
22Part3 = Instance.new("Part")
23BlockMesh4 = Instance.new("BlockMesh")
24IntValue5 = Instance.new("IntValue")
25IntValue6 = Instance.new("IntValue")
26IntValue7 = Instance.new("IntValue")
27Part8 = Instance.new("Part")
28BlockMesh9 = Instance.new("BlockMesh")
29Part10 = Instance.new("Part")
30CylinderMesh11 = Instance.new("CylinderMesh")
31Part12 = Instance.new("Part")
32PointLight13 = Instance.new("PointLight")
33ParticleEmitter14 = Instance.new("ParticleEmitter")
34ParticleEmitter15 = Instance.new("ParticleEmitter")
35Part16 = Instance.new("Part")
36Sound17 = Instance.new("Sound")
37Part18 = Instance.new("Part")
38SpecialMesh19 = Instance.new("SpecialMesh")
39Decal20 = Instance.new("Decal")
40Script21 = Instance.new("Script")
41Script22 = Instance.new("Script")
42ObjectValue23 = Instance.new("ObjectValue")
43RemoteFunction24 = Instance.new("RemoteFunction")
44RemoteFunction25 = Instance.new("RemoteFunction")
45RemoteFunction26 = Instance.new("RemoteFunction")
46RemoteEvent27 = Instance.new("RemoteEvent")
47RemoteFunction28 = Instance.new("RemoteFunction")
48RemoteFunction29 = Instance.new("RemoteFunction")
49RemoteFunction30 = Instance.new("RemoteFunction")
50LocalScript31 = Instance.new("LocalScript")
51IntValue32 = Instance.new("IntValue")
52RemoteEvent33 = Instance.new("RemoteEvent")
53RemoteEvent34 = Instance.new("RemoteEvent")
54RemoteEvent35 = Instance.new("RemoteEvent")
55RemoteEvent36 = Instance.new("RemoteEvent")
56LocalScript37 = Instance.new("LocalScript")
57IntValue38 = Instance.new("IntValue")
58Folder39 = Instance.new("Folder")
59Script40 = Instance.new("Script")
60RemoteFunction41 = Instance.new("RemoteFunction")
61ObjectValue42 = Instance.new("ObjectValue")
62Script43 = Instance.new("Script")
63RemoteFunction44 = Instance.new("RemoteFunction")
64ObjectValue45 = Instance.new("ObjectValue")
65Script46 = Instance.new("Script")
66ObjectValue47 = Instance.new("ObjectValue")
67RemoteFunction48 = Instance.new("RemoteFunction")
68Script49 = Instance.new("Script")
69RemoteFunction50 = Instance.new("RemoteFunction")
70ObjectValue51 = Instance.new("ObjectValue")
71Script52 = Instance.new("Script")
72RemoteFunction53 = Instance.new("RemoteFunction")
73ObjectValue54 = Instance.new("ObjectValue")
74Script55 = Instance.new("Script")
75RemoteFunction56 = Instance.new("RemoteFunction")
76ObjectValue57 = Instance.new("ObjectValue")
77Script58 = Instance.new("Script")
78ObjectValue59 = Instance.new("ObjectValue")
79RemoteFunction60 = Instance.new("RemoteFunction")
80Folder61 = Instance.new("Folder")
81ScreenGui62 = Instance.new("ScreenGui")
82ImageLabel63 = Instance.new("ImageLabel")
83NumberValue64 = Instance.new("NumberValue")
84Frame65 = Instance.new("Frame")
85ImageLabel66 = Instance.new("ImageLabel")
86TextLabel67 = Instance.new("TextLabel")
87Frame68 = Instance.new("Frame")
88TextLabel69 = Instance.new("TextLabel")
89Frame70 = Instance.new("Frame")
90TextLabel71 = Instance.new("TextLabel")
91Frame72 = Instance.new("Frame")
92TextLabel73 = Instance.new("TextLabel")
93Frame74 = Instance.new("Frame")
94TextLabel75 = Instance.new("TextLabel")
95Frame76 = Instance.new("Frame")
96Frame77 = Instance.new("Frame")
97TextLabel78 = Instance.new("TextLabel")
98TextLabel79 = Instance.new("TextLabel")
99TextLabel80 = Instance.new("TextLabel")
100TextLabel81 = Instance.new("TextLabel")
101TextLabel82 = Instance.new("TextLabel")
102Frame83 = Instance.new("Frame")
103TextLabel84 = Instance.new("TextLabel")
104TextLabel85 = Instance.new("TextLabel")
105TextLabel86 = Instance.new("TextLabel")
106Frame87 = Instance.new("Frame")
107TextLabel88 = Instance.new("TextLabel")
108Frame89 = Instance.new("Frame")
109Frame90 = Instance.new("Frame")
110Frame91 = Instance.new("Frame")
111Frame92 = Instance.new("Frame")
112Frame93 = Instance.new("Frame")
113Frame94 = Instance.new("Frame")
114Frame95 = Instance.new("Frame")
115Frame96 = Instance.new("Frame")
116Frame97 = Instance.new("Frame")
117Frame98 = Instance.new("Frame")
118Frame99 = Instance.new("Frame")
119Frame100 = Instance.new("Frame")
120Frame101 = Instance.new("Frame")
121Frame102 = Instance.new("Frame")
122Frame103 = Instance.new("Frame")
123Frame104 = Instance.new("Frame")
124Frame105 = Instance.new("Frame")
125Frame106 = Instance.new("Frame")
126Frame107 = Instance.new("Frame")
127Frame108 = Instance.new("Frame")
128Frame109 = Instance.new("Frame")
129Frame110 = Instance.new("Frame")
130Frame111 = Instance.new("Frame")
131Frame112 = Instance.new("Frame")
132Frame113 = Instance.new("Frame")
133Frame114 = Instance.new("Frame")
134TextLabel115 = Instance.new("TextLabel")
135TextLabel116 = Instance.new("TextLabel")
136TextLabel117 = Instance.new("TextLabel")
137TextLabel118 = Instance.new("TextLabel")
138Frame119 = Instance.new("Frame")
139Frame120 = Instance.new("Frame")
140ImageLabel121 = Instance.new("ImageLabel")
141TextLabel122 = Instance.new("TextLabel")
142TextLabel123 = Instance.new("TextLabel")
143Frame124 = Instance.new("Frame")
144ImageLabel125 = Instance.new("ImageLabel")
145TextLabel126 = Instance.new("TextLabel")
146TextLabel127 = Instance.new("TextLabel")
147Frame128 = Instance.new("Frame")
148TextLabel129 = Instance.new("TextLabel")
149TextLabel130 = Instance.new("TextLabel")
150TextLabel131 = Instance.new("TextLabel")
151Frame132 = Instance.new("Frame")
152Frame133 = Instance.new("Frame")
153ImageLabel134 = Instance.new("ImageLabel")
154ImageLabel135 = Instance.new("ImageLabel")
155Frame136 = Instance.new("Frame")
156TextLabel137 = Instance.new("TextLabel")
157Frame138 = Instance.new("Frame")
158ImageLabel139 = Instance.new("ImageLabel")
159ImageLabel140 = Instance.new("ImageLabel")
160Frame141 = Instance.new("Frame")
161Frame142 = Instance.new("Frame")
162LocalScript143 = Instance.new("LocalScript")
163TextLabel144 = Instance.new("TextLabel")
164Tool0.Name = "M4"
165Tool0.Parent = mas
166IntValue1.Name = "LethalGrenades"
167IntValue1.Parent = Tool0
168IntValue1.Value = 15
169IntValue2.Name = "Ammo"
170IntValue2.Parent = Tool0
171IntValue2.Value = 30
172Part3.Name = "AimPart"
173Part3.Parent = Tool0
174Part3.Transparency = 1
175Part3.Anchored = true
176Part3.CanCollide = false
177Part3.FormFactor = Enum.FormFactor.Custom
178Part3.Size = Vector3.new(0.299999654, 0.200000003, 0.200000152)
179Part3.CFrame = CFrame.new(-6.5369978, 1.43802094, 27.7399979, 0.99999547, 2.98019387e-08, 0, -2.98019387e-08, 0.99999547, 0, 0, 0, 1)
180Part3.BottomSurface = Enum.SurfaceType.Smooth
181Part3.TopSurface = Enum.SurfaceType.Smooth
182Part3.Position = Vector3.new(-6.5369978, 1.43802094, 27.7399979)
183BlockMesh4.Parent = Part3
184BlockMesh4.Scale = Vector3.new(1, 0.999997616, 1)
185BlockMesh4.Scale = Vector3.new(1, 0.999997616, 1)
186IntValue5.Name = "TacticalGrenades"
187IntValue5.Parent = Tool0
188IntValue5.Value = 15
189IntValue6.Name = "ClipSize"
190IntValue6.Parent = Tool0
191IntValue6.Value = 30
192IntValue7.Name = "StoredAmmo"
193IntValue7.Parent = Tool0
194IntValue7.Value = 372
195Part8.Name = "IronSight"
196Part8.Parent = Tool0
197Part8.Material = Enum.Material.Neon
198Part8.BrickColor = BrickColor.new("Really red")
199Part8.Rotation = Vector3.new(-180, 0, -90)
200Part8.Anchored = true
201Part8.CanCollide = false
202Part8.FormFactor = Enum.FormFactor.Custom
203Part8.Size = Vector3.new(0.200000003, 0.200000003, 0.200000003)
204Part8.CFrame = CFrame.new(-6.53726578, 1.41759896, 25.3293209, -3.70249921e-29, 1, 1.91068652e-15, 1, 0, 4.37113954e-08, 4.37113954e-08, 1.91068441e-15, -1)
205Part8.BottomSurface = Enum.SurfaceType.Smooth
206Part8.TopSurface = Enum.SurfaceType.Smooth
207Part8.Color = Color3.new(1, 0, 0)
208Part8.Position = Vector3.new(-6.53726578, 1.41759896, 25.3293209)
209Part8.Orientation = Vector3.new(0, 180, 90)
210Part8.Color = Color3.new(1, 0, 0)
211BlockMesh9.Parent = Part8
212BlockMesh9.Scale = Vector3.new(0.194285721, 0.0285714287, 0.221999988)
213BlockMesh9.Scale = Vector3.new(0.194285721, 0.0285714287, 0.221999988)
214Part10.Name = "A1"
215Part10.Parent = Tool0
216Part10.Material = Enum.Material.SmoothPlastic
217Part10.Rotation = Vector3.new(90, 90, 0)
218Part10.Anchored = true
219Part10.CanCollide = false
220Part10.FormFactor = Enum.FormFactor.Custom
221Part10.Size = Vector3.new(0.200000003, 0.466666698, 0.200000003)
222Part10.CFrame = CFrame.new(-6.5317111, 1.04854596, 26.7070999, 4.37113883e-08, 1.91068441e-15, 1, 1, 4.37113812e-08, -4.37113883e-08, -4.37113812e-08, 1, 0)
223Part10.BottomSurface = Enum.SurfaceType.Smooth
224Part10.TopSurface = Enum.SurfaceType.Smooth
225Part10.Position = Vector3.new(-6.5317111, 1.04854596, 26.7070999)
226Part10.Orientation = Vector3.new(0, 90, 90)
227CylinderMesh11.Parent = Part10
228Part12.Name = "Main"
229Part12.Parent = Tool0
230Part12.Material = Enum.Material.SmoothPlastic
231Part12.BrickColor = BrickColor.new("Bright orange")
232Part12.Transparency = 1
233Part12.Rotation = Vector3.new(90, 0, -180)
234Part12.Anchored = true
235Part12.CanCollide = false
236Part12.FormFactor = Enum.FormFactor.Custom
237Part12.Size = Vector3.new(0.200000003, 0.200000003, 0.200000003)
238Part12.CFrame = CFrame.new(-6.53726578, 1.04854596, 24.1729717, -1, 8.76726158e-09, -2.70801581e-09, 2.70801537e-09, -5.96046377e-08, -1, -8.76726158e-09, -1, 5.96046377e-08)
239Part12.BottomSurface = Enum.SurfaceType.Smooth
240Part12.TopSurface = Enum.SurfaceType.Smooth
241Part12.Color = Color3.new(0.854902, 0.521569, 0.254902)
242Part12.Position = Vector3.new(-6.53726578, 1.04854596, 24.1729717)
243Part12.Orientation = Vector3.new(90, 180, 0)
244Part12.Color = Color3.new(0.854902, 0.521569, 0.254902)
245PointLight13.Name = "FlashFX[Light]"
246PointLight13.Parent = Part12
247PointLight13.Color = Color3.new(1, 1, 0.498039)
248PointLight13.Enabled = false
249PointLight13.Brightness = 10
250PointLight13.Range = 6
251PointLight13.Shadows = true
252PointLight13.Color = Color3.new(1, 1, 0.498039)
253ParticleEmitter14.Name = "1FlashFX[Smoke]"
254ParticleEmitter14.Parent = Part12
255ParticleEmitter14.Transparency = NumberSequence.new(0.60000002384186,1)
256ParticleEmitter14.Rotation = NumberRange.new(0, 360)
257ParticleEmitter14.Size = NumberSequence.new(0.99999964237213,3)
258ParticleEmitter14.Color = ColorSequence.new(Color3.new(0.27451, 0.27451, 0.27451),Color3.new(0.27451, 0.27451, 0.27451))
259ParticleEmitter14.Enabled = false
260ParticleEmitter14.LightEmission = 0.10000000149012
261ParticleEmitter14.Texture = "http://www.roblox.com/asset/?id=244514423"
262ParticleEmitter14.Lifetime = NumberRange.new(1.25, 1.5)
263ParticleEmitter14.Rate = 100
264ParticleEmitter14.RotSpeed = NumberRange.new(10, 10)
265ParticleEmitter14.Speed = NumberRange.new(5, 7)
266ParticleEmitter14.VelocitySpread = 15
267ParticleEmitter14.Color = ColorSequence.new(Color3.new(0.27451, 0.27451, 0.27451),Color3.new(0.27451, 0.27451, 0.27451))
268ParticleEmitter15.Name = "FlashFX[Flash]"
269ParticleEmitter15.Parent = Part12
270ParticleEmitter15.Transparency = NumberSequence.new(0.75,1)
271ParticleEmitter15.Rotation = NumberRange.new(0, 90)
272ParticleEmitter15.Size = NumberSequence.new(0.5,0)
273ParticleEmitter15.Color = ColorSequence.new(Color3.new(1, 1, 0.498039),Color3.new(1, 1, 0.498039))
274ParticleEmitter15.Enabled = false
275ParticleEmitter15.LightEmission = 1
276ParticleEmitter15.Texture = "http://www.roblox.com/asset/?id=3419963"
277ParticleEmitter15.Lifetime = NumberRange.new(0.050000000745058, 0.075000002980232)
278ParticleEmitter15.Rate = 1000
279ParticleEmitter15.Speed = NumberRange.new(50, 50)
280ParticleEmitter15.Color = ColorSequence.new(Color3.new(1, 1, 0.498039),Color3.new(1, 1, 0.498039))
281Part16.Name = "Handle"
282Part16.Parent = Tool0
283Part16.Material = Enum.Material.SmoothPlastic
284Part16.BrickColor = BrickColor.new("Dark stone grey")
285Part16.Transparency = 1
286Part16.Anchored = true
287Part16.CanCollide = false
288Part16.FormFactor = Enum.FormFactor.Custom
289Part16.Size = Vector3.new(0.200000003, 0.200000003, 0.200000003)
290Part16.CFrame = CFrame.new(-6.53726578, 0.426804006, 27.3014355, 1, 4.37113883e-08, 1.91068441e-15, -4.37113883e-08, 1, 4.37113812e-08, 0, -4.37113812e-08, 1)
291Part16.BottomSurface = Enum.SurfaceType.Smooth
292Part16.TopSurface = Enum.SurfaceType.Smooth
293Part16.Color = Color3.new(0.388235, 0.372549, 0.384314)
294Part16.Position = Vector3.new(-6.53726578, 0.426804006, 27.3014355)
295Part16.Color = Color3.new(0.388235, 0.372549, 0.384314)
296Sound17.Name = "FireSound"
297Sound17.Parent = Part16
298Sound17.Pitch = 1.6000000238419
299Sound17.SoundId = "http://roblox.com/asset/?id=10209859"
300Sound17.Volume = 1
301Part18.Name = "SightBack"
302Part18.Parent = Tool0
303Part18.Material = Enum.Material.SmoothPlastic
304Part18.BrickColor = BrickColor.new("Dark stone grey")
305Part18.Rotation = Vector3.new(180, 0, 180)
306Part18.Anchored = true
307Part18.CanCollide = false
308Part18.FormFactor = Enum.FormFactor.Custom
309Part18.Size = Vector3.new(0.200000003, 0.200000003, 0.200000003)
310Part18.CFrame = CFrame.new(-6.53726578, 1.43791997, 27.2404385, -1, -1.07284414e-07, -8.51092014e-15, -1.07284414e-07, 1, -1.94707184e-07, 2.93999681e-14, -1.94707184e-07, -1)
311Part18.BottomSurface = Enum.SurfaceType.Smooth
312Part18.TopSurface = Enum.SurfaceType.Smooth
313Part18.Color = Color3.new(0.388235, 0.372549, 0.384314)
314Part18.Position = Vector3.new(-6.53726578, 1.43791997, 27.2404385)
315Part18.Orientation = Vector3.new(0, -180, 0)
316Part18.Color = Color3.new(0.388235, 0.372549, 0.384314)
317SpecialMesh19.Parent = Part18
318SpecialMesh19.MeshId = "http://www.roblox.com/asset/?id=3270017"
319SpecialMesh19.Scale = Vector3.new(0.102857143, 0.102857143, 0.140000001)
320SpecialMesh19.MeshType = Enum.MeshType.FileMesh
321SpecialMesh19.Scale = Vector3.new(0.102857143, 0.102857143, 0.140000001)
322Decal20.Parent = mas
323Decal20.Texture = "http://www.roblox.com/asset/?id=29849324"
324Script21.Name = "[[README]]"
325Script21.Parent = Tool0
326table.insert(cors,sandbox(Script21,function()
327--[[
328
329 VERSION: v0.0.4
330
331 ----------[ UPDATES ]----------------------------------------------------
332
333 Pre-Release: -Added a copyright
334 -fixed the issue where you couldn't run when you selected the tool
335 -Added an ADS key and allowed ADS to either be toggle or hold
336 -Made the Ammo values external so they can be changed by outside scripts
337
338 v0.0.2: -Created new arms for the gun
339 -Fixed an issue where the arms would glitch if PlayerAnimations was set to false and the gun was fired
340 -Updated credit security
341 -Put the Arm cframes in the SETTINGS
342 -Made the stance changing animations slightly smoother
343 -Added bullet drop
344 -Fixed some bullet hit handling code
345 -Made the torso being able to rotate while sitting down a setting
346 -Added bullet settings
347 -Added shockwave settings
348 -Added an Explosive guntype
349 -Added a version label in the Gui
350
351 v0.0.3: -Added an option to have player arms
352 -Added grenades / throwables
353 -Fixed the issue where if a player left a server without deselecting the gun, the bullet trails still remained
354 -Added Gui Scopes
355 -Fixed the issue where the guns would glitch if you switched weapons too fast
356
357 v0.0.4: -Updated the Gui
358 -Added a "Table Of Contents" in the clientMain
359 -Added PLUGINS
360 -Added the Arm CFrame when Running in the SETTINGS
361 -Added Mouse Sensitivity settings
362 -Fixed an issue where a humanoid wouldn't be damaged by bullets if there was no space between a wall and the humanoid
363 -Fixed the issue where you couldn't steady the scope if the steady key was different from the run key
364 -Added an example flashlight and laser (You can delete them and the gun will still work fine)
365 -Moved the movement animations into a separate module script for easier editing
366 -Added a single bullet mag option. It allows people to make guns where the mag is the bullet itself (i.e. arrows)
367 -Moved grenades into a seperate folder and made them server-side so they don't get deleted when you die or switch guns
368 -Added an option for a second knife animation
369 -Added a setting to change the throwing speed of the grenades
370 -Added an auto-knife feature
371 -Added a setting for whether the gun can ADS or not
372 -Added a flashbang and a molotov to the grenade list
373 -Fixed an issue where bullets could only penetrate 1 wall
374 -Added gun sway for when you move the gun around
375 -Made the camera type scriptable when the gun is selected
376 -Moved the ignore model creating code into a seperate server script so the ReadMe can be deleted
377 -Redesigned the animations so the transitions between idling, walking, and running are smooth instead of choppy like previously
378 -Added a fire select option
379 -Added an equip animation option
380 -Added a crawling animation option
381 -Fixed the issue where you could dive and jump at the same time
382 -Moved the reload animation into the ANIMATIONS modulescript for easier editing
383 -Added an option to enable reloading while running
384 -Added an option to enable firing while running
385 -Redesigned the recoil animation and based it more on battlefield
386 -Edited the reload so if a bullet is already chambered and you reload the ammo will be the ClipSize + 1
387 -Fixed the issue where the ammo would go to 0 if you stopped the reload
388 -Fixed the issue where if you stopped the reload before you put in a new mag the gun would take another full clipsize from the storedammo
389 -Fixed an issue where if the gun was removed without being deselected, the camera would break
390 -Got rid of the gunName and gunDescription settings because they're unnecessary and annoying to change
391 -Moved bullet impact object creation to server side
392 -Added a bullet smoke impact setting
393 -Added a blood particle setting that appears on a player when they're shot
394 -Updated the scope
395 -Added CanCollide, transparency, and custom ignore settings to the penetration settings
396 -Moved trail creation to server side to prevent client lag
397 -Fixed an issue where shooting a player's hat would do damage
398
399 -------------------------------------------------------------------------
400
401 Hello there!
402
403 Glad to know you're using my one and only Gun Kit!
404
405 Even though this kit has many features and is rather advanced, it's pretty easy to use
406
407 There are 4 things that this gun needs in order to function:
408 One brick called "AimPart"
409 At least one brick where the first 3 letters are "Mag"
410 One brick called "Handle"
411 One brick called "Main"
412
413 The AimPart is what the gun will use to aim down the sights. When you aim down your sights, this brick will be in the center
414 of the player's head. It basically allows the gun to have any type of sight, which can be placed anywhere on the gun. As long as
415 the AimPart is aligned with the sight, the gun will aim down the sights properly.
416 (NOTE: Make sure the AimPart is behind the Sight and the FRONT of the AimPart is facing the Sight)
417
418 The Mag is what the gun will move around when you reload the gun. If the mag is made up of more than one brick, make sure the first
419 3 leters of the bricks are also "Mag" so that the gun will move them around. If you set ReloadAnimation to false in the SETTINGS, you don't
420 need any bricks called "Mag". But if ReloadAnimation is set to true, the gun needs at least one brick called "Mag" or it will break. It doesn't
421 matter what comes after the "Mag", you can have a Mag brick called "Mag1" and another Mag brick called "MagA". As long as the first three letters are
422 "Mag", then the gun will recognize it as a Mag
423
424 The Handle is obviously the most important part of the Gun. Without it, the tool itself wouldn't work. It's that simple
425 (NOTE: If you want a sound to play when you fire, name it "FireSound" and place it in the Handle. If you want a sound to play when
426 you reload, name it "ReloadSound" and place it in the Handle)
427
428 The Main is the brick where the bullets will originate from. It's also the brick where the flash effects are kept.
429 (NOTE: If you want a muzzle flash effects, put them in the Main and call them "FlashFX". Also make sure they have an "Enabled"
430 property so that the script can enable and disable them)
431
432 ----------[ INSTRUCTIONS ]-----------------------------------------------
433
434 HOW TO USE THIS KIT:
435 1) If the gun already has a Handle, make sure it is facing forward. If the gun doesn't have a Handle, create one and place
436 it wherever you like, and make sure it is facing forward
437
438 2) If the gun already has a brick called "AimPart", move it to where you would like, and make sure it is facing the sight.
439 If the gun doesn't have a brick called "AimPart", create one and move it where you would like it to be, and make sure
440 it is facing the sight
441
442 3) If the gun already has a brick called "Main", move it to the very front of the gun. If the gun doesn't have a brick
443 called "Main", create one and move it to the very front of the gun
444
445 4) If ReloadAnimation is set to true in the SETTINGS, make sure the gun has at least one brick called "Mag". If
446 ReloadAnimation is set to false, the gun doesn't need any bricks called "Mag".
447
448 5) Open the SETTINGS and edit them however you like
449
450 That's it! Only 5 steps! It's not that complicated, just follow the Directions and it should work fine. If you have any questions /
451 comments / concerns, message me.
452
453 ______ ______ __ ______ _ ______
454 / _/ _/ /_ __/_ _______/ /_ ____ / ____/_ _______(_)___ ____ / / /
455 / // / / / / / / / ___/ __ \/ __ \/ /_ / / / / ___/ / __ \/ __ \ / // /
456 / // / / / / /_/ / / / /_/ / /_/ / __/ / /_/ (__ ) / /_/ / / / / / // /
457 / // / /_/ \__,_/_/ /_.___/\____/_/ \__,_/____/_/\____/_/ /_/ _/ // /
458 /__/__/ /__/__/
459
460--]]
461end))
462Script22.Name = "serverMain"
463Script22.Parent = Tool0
464table.insert(cors,sandbox(Script22,function()
465local Plyr = script:WaitForChild("Plyr")
466
467local Gun = script.Parent
468local Handle = Gun:WaitForChild("Handle")
469
470local V3 = Vector3.new
471local CF, CFANG = CFrame.new, CFrame.Angles
472
473local RAD = math.rad
474
475local numLerp = function(A, B, Alpha)
476 return A + (B - A) * Alpha
477end
478
479local inList = function(Element, List)
480 for _, v in pairs(List) do
481 if v == Element then
482 return true
483 end
484 end
485 return false
486end
487
488local getObject = function(Model, Class, Name)
489 for _, v in pairs(Model:GetChildren()) do
490 if v:IsA(Class) and v.Name == Name then
491 return v
492 end
493 end
494 return nil
495end
496
497----------------------------------------------------------------------
498--------------------[ IGNORE MODEL HANDLING ]-------------------------
499----------------------------------------------------------------------
500
501wait(math.random(0, 20) / 40) --This is to prevent more than one ignoreModel from being created
502
503if _G.ignoreCode then --If the ignoreCode already exists, then the script creates the ignoreModel
504 --[[
505 The purpose of this is so that every gun in a game that uses this gun kit will share one ignoreModel. That way,
506 bullet trails, bullet holes, and other fake arms will be ignored by the gun which makes the bullets more likely to
507 hit a character part
508 --]]
509 if (not game.Workspace:FindFirstChild("ignoreModel_".._G.ignoreCode)) then
510 local ignoreModel = Instance.new("Model")
511 ignoreModel.Name = "ignoreModel_".._G.ignoreCode
512 ignoreModel.Parent = game.Workspace
513
514 local grenadeFolder = Instance.new("Model")
515 grenadeFolder.Name = "grenadeFolder"
516 grenadeFolder.Parent = ignoreModel
517
518 spawn(function()
519 while true do
520 ignoreModel.Parent = game.Workspace
521 grenadeFolder.Parent = ignoreModel
522 wait(1 / 20)
523 end
524 end)
525 end
526
527 script.Parent:WaitForChild("clientMain"):WaitForChild("ignoreCode").Value = _G.ignoreCode
528else
529 --[[
530 If there isn't already an ignoreCode, then this creates one. The purpose of it being random is so that if there is
531 an ignoreModel for something else in the game, the script won't end up placing the ignored objects in that ignoreModel
532 --]]
533 _G.ignoreCode = math.random(1, 1e4)
534
535 if (not game.Workspace:FindFirstChild("ignoreModel_".._G.ignoreCode)) then
536 local ignoreModel = Instance.new("Model")
537 ignoreModel.Name = "ignoreModel_".._G.ignoreCode
538 ignoreModel.Parent = game.Workspace
539
540 local grenadeFolder = Instance.new("Model")
541 grenadeFolder.Name = "grenadeFolder"
542 grenadeFolder.Parent = ignoreModel
543
544 spawn(function()
545 while true do
546 ignoreModel.Parent = game.Workspace
547 grenadeFolder.Parent = ignoreModel
548 wait(1 / 20)
549 end
550 end)
551 end
552
553 script.Parent:WaitForChild("clientMain"):WaitForChild("ignoreCode").Value = _G.ignoreCode
554end
555
556spawn(function()
557 --[[
558 This function deletes any Player Folders that were left in the ignoreModel because the player left the game without
559 deselecting the Gun first
560 --]]
561 repeat wait() until _G.ignoreCode
562 local ignoreModel = game.Workspace:WaitForChild("ignoreModel_".._G.ignoreCode)
563 while true do
564 for _, gunIgnore in pairs(ignoreModel:GetChildren()) do
565 if gunIgnore.Name ~= "grenadeFolder" then
566 if (not game.Players:FindFirstChild(gunIgnore.Name:sub(11))) then
567 gunIgnore:Destroy()
568 end
569 end
570 end
571 wait(1 / 20)
572 end
573end)
574
575----------------------------------------------------------------------
576--------------------[ RESET CAMERA ]----------------------------------
577----------------------------------------------------------------------
578
579Gun.ChildRemoved:connect(function(Child)
580 if Child == Handle and Plyr.Value then
581 local ignoreCode = Gun:WaitForChild("clientMain"):WaitForChild("ignoreCode").Value
582 local resetCam = script:WaitForChild("resetCam")
583 resetCam:WaitForChild("ignoreCode").Value = ignoreCode
584 resetCam.Parent = Plyr.Value.PlayerGui
585 end
586end)
587
588----------------------------------------------------------------------
589--------------------[ GET WELD CFRAMES ]------------------------------
590----------------------------------------------------------------------
591
592for _, v in pairs(Gun:GetChildren()) do
593 if v:IsA("BasePart") and v ~= Handle then
594 if v:FindFirstChild("mainWeld") then v.mainWeld:Destroy() end
595 if (not v:FindFirstChild("weldCF")) then
596 local weldCF = Instance.new("CFrameValue")
597 weldCF.Name = "weldCF"
598 weldCF.Value = Handle.CFrame:toObjectSpace(v.CFrame)
599 weldCF.Parent = v
600 end
601 if string.sub(v.Name, 1, 3) == "Mag" then
602 if (not v:FindFirstChild("magTrans")) then
603 local magTrans = Instance.new("NumberValue")
604 magTrans.Name = "magTrans"
605 magTrans.Value = v.Transparency
606 magTrans.Parent = v
607 end
608 end
609 v.Anchored = true
610 v.CanCollide = false
611 end
612end
613Handle.Anchored = false
614Handle.CanCollide = true
615
616----------------------------------------------------------------------
617--------------------[ GUNSETUP HANDLING ]-----------------------------
618----------------------------------------------------------------------
619
620local gunSetup = script:WaitForChild("gunSetup")
621function gunSetup.OnServerInvoke(Player, Vars)
622
623 --------------------[ CREATING IGNORE MODELS ]--------------------------------
624
625 local gunIgnore = Instance.new("Model")
626 gunIgnore.Name = "gunIgnore_"..Player.Name
627 gunIgnore.Parent = Vars.ignoreModel
628
629 --------------------[ MODIFYING THE PLAYER ]----------------------------------
630
631 Vars.Humanoid.AutoRotate = false
632
633 Vars.Shoulders.Right.Part1 = nil
634 Vars.Shoulders.Left.Part1 = nil
635
636 local playerFolder = Instance.new("Model")
637 playerFolder.Name = "playerFolder"
638 playerFolder.Parent = gunIgnore
639
640 local headBase = Instance.new("Part")
641 headBase.Transparency = 1
642 headBase.Name = "headBase"
643 headBase.CanCollide = false
644 headBase.FormFactor = Enum.FormFactor.Custom
645 headBase.Size = V3(0.2, 0.2, 0.2)
646 headBase.BottomSurface = Enum.SurfaceType.Smooth
647 headBase.TopSurface = Enum.SurfaceType.Smooth
648 headBase.Parent = playerFolder
649
650 local headWeld = Instance.new("Weld")
651 headWeld.Part0 = Vars.Torso
652 headWeld.Part1 = headBase
653 headWeld.C0 = CF(0, 1.5, 0)
654 headWeld.Parent = Vars.Torso
655
656 local headWeld2 = Instance.new("Weld")
657 headWeld2.Part0 = headBase
658 headWeld2.Part1 = Vars.Head
659 headWeld2.Parent = headBase
660
661 local animBase = Instance.new("Part")
662 animBase.Transparency = 1
663 animBase.Name = "animBase"
664 animBase.CanCollide = false
665 animBase.FormFactor = Enum.FormFactor.Custom
666 animBase.Size = V3(0.2, 0.2, 0.2)
667 animBase.BottomSurface = Enum.SurfaceType.Smooth
668 animBase.TopSurface = Enum.SurfaceType.Smooth
669 animBase.Parent = playerFolder
670
671 local animWeld = Instance.new("Weld")
672 animWeld.Part0 = animBase
673 animWeld.Part1 = headBase
674 animWeld.Parent = animBase
675
676 local armBase = Instance.new("Part")
677 armBase.Transparency = 1
678 armBase.Name = "ArmBase"
679 armBase.CanCollide = false
680 armBase.FormFactor = Enum.FormFactor.Custom
681 armBase.Size = V3(0.2, 0.2, 0.2)
682 armBase.BottomSurface = Enum.SurfaceType.Smooth
683 armBase.TopSurface = Enum.SurfaceType.Smooth
684 armBase.Parent = playerFolder
685
686 local ABWeld = Instance.new("Weld")
687 ABWeld.Part0 = armBase
688 ABWeld.Part1 = animBase
689 ABWeld.Parent = armBase
690
691 local LArmBase = Instance.new("Part")
692 LArmBase.Transparency = 1
693 LArmBase.Name = "LArmBase"
694 LArmBase.CanCollide = false
695 LArmBase.FormFactor = Enum.FormFactor.Custom
696 LArmBase.Size = V3(0.2, 0.2, 0.2)
697 LArmBase.BottomSurface = Enum.SurfaceType.Smooth
698 LArmBase.TopSurface = Enum.SurfaceType.Smooth
699 LArmBase.Parent = playerFolder
700
701 local RArmBase = Instance.new("Part")
702 RArmBase.Transparency = 1
703 RArmBase.Name = "RArmBase"
704 RArmBase.CanCollide = false
705 RArmBase.FormFactor = Enum.FormFactor.Custom
706 RArmBase.Size = V3(0.2, 0.2, 0.2)
707 RArmBase.BottomSurface = Enum.SurfaceType.Smooth
708 RArmBase.TopSurface = Enum.SurfaceType.Smooth
709 RArmBase.Parent = playerFolder
710
711 local LWeld = Instance.new("Weld")
712 LWeld.Name = "LWeld"
713 LWeld.Part0 = armBase
714 LWeld.Part1 = LArmBase
715 LWeld.C0 = Vars.armC0[1]
716 LWeld.C1 = Vars.leftArmC1
717 LWeld.Parent = armBase
718
719 local RWeld = Instance.new("Weld")
720 RWeld.Name = "RWeld"
721 RWeld.Part0 = armBase
722 RWeld.Part1 = RArmBase
723 RWeld.C0 = Vars.armC0[2]
724 RWeld.C1 = Vars.rightArmC1
725 RWeld.Parent = armBase
726
727 local LWeld2 = Instance.new("Weld")
728 LWeld2.Name = "LWeld"
729 LWeld2.Part0 = LArmBase
730 LWeld2.Part1 = Vars.LArm
731 LWeld2.Parent = LArmBase
732
733 local RWeld2 = Instance.new("Weld")
734 RWeld2.Name = "RWeld"
735 RWeld2.Part0 = RArmBase
736 RWeld2.Part1 = Vars.RArm
737 RWeld2.Parent = RArmBase
738
739 local LLegWeld = Instance.new("Weld")
740 LLegWeld.Name = "LLegWeld"
741 LLegWeld.Part0 = Vars.Torso
742 LLegWeld.Part1 = nil
743 LLegWeld.C0 = CF(-0.5, -2, 0)
744 LLegWeld.Parent = Vars.Torso
745
746 local RLegWeld = Instance.new("Weld")
747 RLegWeld.Name = "RLegWeld"
748 RLegWeld.Part0 = Vars.Torso
749 RLegWeld.Part1 = nil
750 RLegWeld.C0 = CF(0.5, -2, 0)
751 RLegWeld.Parent = Vars.Torso
752
753 for _, Tab in pairs(Vars.gunParts) do
754 Tab.Obj.Anchored = false
755 local Weld = Instance.new("Weld")
756 Weld.Name = "mainWeld"
757 Weld.Part0 = Vars.Handle
758 Weld.Part1 = Tab.Obj
759 Weld.C0 = Tab.Obj.weldCF.Value
760 Weld.Parent = Vars.Handle
761 Tab.Weld = Weld
762 end
763
764 return gunIgnore, playerFolder, headWeld, headWeld2, animWeld, ABWeld, LWeld, RWeld, LWeld2, RWeld2, LLegWeld, RLegWeld, Vars.gunParts
765end
766
767----------------------------------------------------------------------
768--------------------[ TWEENJOINT HANDLING ]---------------------------
769----------------------------------------------------------------------
770
771local createTweenIndicator = script:WaitForChild("createTweenIndicator")
772function createTweenIndicator.OnServerInvoke(_, Joint, newCode)
773 local tweenIndicator = nil
774 if (not Joint:findFirstChild("tweenCode")) then --If the joint isn't being tweened, then
775 tweenIndicator = Instance.new("IntValue")
776 tweenIndicator.Name = "tweenCode"
777 tweenIndicator.Value = newCode
778 tweenIndicator.Parent = Joint
779 else
780 tweenIndicator = Joint.tweenCode
781 tweenIndicator.Value = newCode --If the joint is already being tweened, this will change the code, and the tween loop will stop
782 end
783 return tweenIndicator
784end
785
786local lerpCF = script:WaitForChild("lerpCF")
787function lerpCF.OnServerInvoke(_, Joint, Prop, startCF, endCF, Alpha)
788 spawn(function()
789 Joint[Prop] = startCF:lerp(endCF, Alpha)
790 end)
791end
792
793local deleteTweenIndicator = script:WaitForChild("deleteTweenIndicator")
794function deleteTweenIndicator.OnServerInvoke(_, tweenIndicator, newCode)
795 if tweenIndicator.Value == newCode then --If this tween functions was the last one called on a joint then it will remove the code
796 tweenIndicator:Destroy()
797 end
798end
799
800----------------------------------------------------------------------
801--------------------[ BULLET IMPACT HANDLING ]------------------------
802----------------------------------------------------------------------
803
804local createBulletImpact = script:WaitForChild("createBulletImpact")
805createBulletImpact.OnServerEvent:connect(function(_, H, P, N, D, humanoidFound, gunIgnore, S)
806 local surfaceCF = CF(P, P + N)
807 ----------------------------------------------------------------------------------
808 --Creating the bullet hole--------------------------------------------------------
809 ----------------------------------------------------------------------------------
810 if S.bulletHoles and (not humanoidFound) then
811 local Hole = Instance.new("Part")
812 Hole.Transparency = 1
813 Hole.Anchored = true
814 Hole.CanCollide = false
815 Hole.FormFactor = "Custom"
816 Hole.Size = V3(1, 1, 0.2)
817 Hole.TopSurface = 0
818 Hole.BottomSurface = 0
819 local Mesh = Instance.new("BlockMesh")
820 Mesh.Offset = V3(0, 0, -0.05)
821 Mesh.Scale = V3(S.holeSettings.Size, S.holeSettings.Size, 0)
822 Mesh.Parent = Hole
823 local Decal = Instance.new("Decal")
824 Decal.Face = Enum.NormalId.Front
825 Decal.Texture = S.holeSettings.Texture
826 Decal.Parent = Hole
827 Hole.Parent = gunIgnore
828 Hole.CFrame = surfaceCF
829 if (not H.Anchored) then
830 local Weld = Instance.new("Weld", Hole)
831 Weld.Part0 = H
832 Weld.Part1 = Hole
833 Weld.C0 = H.CFrame:toObjectSpace(surfaceCF)
834 Hole.Anchored = false
835 end
836 delay(S.holeSettings.visibleTime, function()
837 if S.holeSettings.disappearTime > 0 then
838 local t0 = tick()
839 while true do
840 local Alpha = math.min((tick() - t0) / S.holeSettings.disappearTime, 1)
841 Decal.Transparency = numLerp(0, 1, Alpha)
842 if Alpha == 1 then break end
843 wait()
844 end
845 Hole:Destroy()
846 else
847 Hole:Destroy()
848 end
849 end)
850 end
851 ----------------------------------------------------------------------------------
852 --Creating the spark effect-------------------------------------------------------
853 ----------------------------------------------------------------------------------
854 if S.bulletSparks and (not humanoidFound) and inList(H.Material, S.sparkSettings.Materials) then
855 local Sparks = Instance.new("Part")
856 Sparks.Transparency = 1
857 Sparks.Anchored = true
858 Sparks.CanCollide = false
859 Sparks.FormFactor = "Custom"
860 Sparks.Size = V3(1, 1, 1)
861 Sparks.TopSurface = 0
862 Sparks.BottomSurface = 0
863
864 local Particles = nil
865 if S.customSparks then
866 Particles = getObject(game.ServerStorage, "ParticleEmitter", "bulletSpark"):Clone()
867 else
868 Particles = Instance.new("ParticleEmitter")
869 Particles.Color = ColorSequence.new(S.sparkSettings.Color.Start, S.sparkSettings.Color.End)
870 Particles.LightEmission = 1
871 Particles.Size = NumberSequence.new(
872 {
873 NumberSequenceKeypoint.new(0, S.sparkSettings.Size, 0.25);
874 NumberSequenceKeypoint.new(1, 0);
875 }
876 )
877 Particles.Texture = S.sparkSettings.Texture
878 Particles.Transparency = NumberSequence.new(0)
879 Particles.Acceleration = V3(0, -196.2, 0)
880 Particles.EmissionDirection = Enum.NormalId.Front
881 Particles.Lifetime = NumberRange.new(S.sparkSettings.Lifetime - 0.05, S.sparkSettings.Lifetime + 0.05)
882 Particles.Rate = S.sparkSettings.Rate
883 Particles.Rotation = NumberRange.new(0, 360)
884 Particles.Speed = NumberRange.new(S.sparkSettings.Speed - 5, S.sparkSettings.Speed + 5)
885 Particles.VelocitySpread = S.sparkSettings.Spread
886 end
887 Particles.Parent = Sparks
888
889 Sparks.Parent = gunIgnore
890 Sparks.CFrame = surfaceCF
891 if (not H.Anchored) then
892 local Weld = Instance.new("Weld", Sparks)
893 Weld.Part0 = H
894 Weld.Part1 = Sparks
895 Weld.C0 = H.CFrame:toObjectSpace(surfaceCF)
896 Sparks.Anchored = false
897 end
898 delay(0.1, function()
899 Particles.Enabled = false
900 wait(Particles.Lifetime.Max)
901 Sparks:Destroy()
902 end)
903 end
904 ----------------------------------------------------------------------------------
905 --Creating the smoke effect-------------------------------------------------------
906 ----------------------------------------------------------------------------------
907 if S.bulletSmoke and (not humanoidFound) then
908 local Smoke = Instance.new("Part")
909 Smoke.Transparency = 1
910 Smoke.Anchored = true
911 Smoke.CanCollide = false
912 Smoke.FormFactor = "Custom"
913 Smoke.Size = V3(1, 1, 1)
914 Smoke.TopSurface = 0
915 Smoke.BottomSurface = 0
916
917 local Particles = Instance.new("ParticleEmitter")
918 Particles.Color = ColorSequence.new(S.smokeSettings.objColor and H.Color or S.smokeSettings.Color)
919 Particles.LightEmission = 0
920 Particles.Size = NumberSequence.new(
921 {
922 NumberSequenceKeypoint.new(0, S.smokeSettings.Size.Start);
923 NumberSequenceKeypoint.new(1, S.smokeSettings.Size.End);
924 }
925 )
926 Particles.Texture = S.smokeSettings.Texture
927 Particles.Transparency = NumberSequence.new(
928 {
929 NumberSequenceKeypoint.new(0, S.smokeSettings.startTransparency);
930 NumberSequenceKeypoint.new(0.5, 0.75 * S.smokeSettings.startTransparency + 0.25);
931 NumberSequenceKeypoint.new(1, 1);
932 }
933 )
934 Particles.Acceleration = V3(0, -196.2, 0)
935 Particles.EmissionDirection = Enum.NormalId.Front
936 Particles.Lifetime = NumberRange.new(S.smokeSettings.Lifetime - 0.05, S.smokeSettings.Lifetime + 0.05)
937 Particles.Rate = S.smokeSettings.Rate
938 Particles.Rotation = NumberRange.new(0, 360)
939 Particles.RotSpeed = NumberRange.new(10)
940 Particles.Speed = NumberRange.new(S.smokeSettings.Speed - 5, S.smokeSettings.Speed + 5)
941 Particles.VelocitySpread = S.smokeSettings.Spread
942 Particles.Parent = Smoke
943
944 Smoke.Parent = gunIgnore
945 Smoke.CFrame = surfaceCF
946 if (not H.Anchored) then
947 local Weld = Instance.new("Weld", Smoke)
948 Weld.Part0 = H
949 Weld.Part1 = Smoke
950 Weld.C0 = H.CFrame:toObjectSpace(surfaceCF)
951 Smoke.Anchored = false
952 end
953 delay(0.1, function()
954 Particles.Enabled = false
955 wait(S.smokeSettings.Lifetime + 0.05)
956 Smoke:Destroy()
957 end)
958 end
959end)
960
961----------------------------------------------------------------------
962--------------------[ SHOCKWAVE HANDLING ]----------------------------
963----------------------------------------------------------------------
964
965local createShockwave = script:WaitForChild("createShockwave")
966createShockwave.OnServerEvent:connect(function(_, Center, Radius, gunIgnore, S)
967 local Shockwave = Instance.new("Part")
968 Shockwave.BrickColor = S.shockwaveSettings.Color
969 Shockwave.Material = Enum.Material.SmoothPlastic
970 Shockwave.Name = "Shockwave"
971 Shockwave.Anchored = true
972 Shockwave.CanCollide = false
973 Shockwave.FormFactor = Enum.FormFactor.Symmetric
974 Shockwave.Size = V3(1, 1, 1)
975 Shockwave.BottomSurface = Enum.SurfaceType.Smooth
976 Shockwave.TopSurface = Enum.SurfaceType.Smooth
977 local Mesh = Instance.new("SpecialMesh")
978 Mesh.MeshType = Enum.MeshType.Sphere
979 Mesh.Scale = V3()
980 Mesh.Parent = Shockwave
981 Shockwave.Parent = gunIgnore
982 Shockwave.CFrame = CF(Center)
983 spawn(function()
984 local t0 = tick()
985 while true do
986 local Alpha = math.min((tick() - t0) / S.shockwaveSettings.Duration, 1)
987 local Scale = 2 * Radius * Alpha
988 Mesh.Scale = V3(Scale, Scale, Scale)
989 Shockwave.Transparency = Alpha
990 if Alpha == 1 then break end
991 wait()
992 end
993 Shockwave:Destroy()
994 end)
995end)
996
997----------------------------------------------------------------------
998--------------------[ BLOOD HANDLING ]--------------------------------
999----------------------------------------------------------------------
1000
1001local createBlood = script:WaitForChild("createBlood")
1002createBlood.OnServerEvent:connect(function(_, H, P, D, gunIgnore, S)
1003 local bloodCF = CF(P, P + D) * CFANG(RAD(-90), 0, 0)
1004 local Blood = Instance.new("Part")
1005 Blood.Transparency = 1
1006 Blood.Anchored = true
1007 Blood.CanCollide = false
1008 Blood.FormFactor = "Custom"
1009 Blood.Size = V3(0.2, 1, 0.2)
1010 Blood.TopSurface = 0
1011 Blood.BottomSurface = 0
1012
1013 local Particles = Instance.new("ParticleEmitter")
1014 Particles.Color = ColorSequence.new(S.bloodSettings.Color)
1015 Particles.LightEmission = 0
1016 Particles.Size = NumberSequence.new(S.bloodSettings.Size)
1017 Particles.Texture = S.bloodSettings.Texture
1018 Particles.Transparency = NumberSequence.new(
1019 {
1020 NumberSequenceKeypoint.new(0, S.bloodSettings.startTransparency);
1021 NumberSequenceKeypoint.new(1, 1);
1022 }
1023 )
1024 Particles.EmissionDirection = Enum.NormalId.Top
1025 Particles.Lifetime = NumberRange.new(S.bloodSettings.Lifetime - 0.05, S.bloodSettings.Lifetime + 0.05)
1026 Particles.Rate = S.bloodSettings.Rate
1027 Particles.Rotation = NumberRange.new(0, 90)
1028 Particles.Speed = NumberRange.new(S.bloodSettings.Speed)
1029 Particles.VelocitySpread = S.bloodSettings.Spread
1030 Particles.Parent = Blood
1031
1032 Blood.Parent = gunIgnore
1033 Blood.CFrame = bloodCF
1034 if (not H.Anchored) then
1035 local Weld = Instance.new("Weld", Blood)
1036 Weld.Part0 = H
1037 Weld.Part1 = Blood
1038 Weld.C0 = H.CFrame:toObjectSpace(bloodCF)
1039 Blood.Anchored = false
1040 end
1041 delay(0.15, function()
1042 Particles.Enabled = false
1043 wait(S.bloodSettings.Lifetime + 0.05)
1044 Blood:Destroy()
1045 end)
1046end)
1047
1048----------------------------------------------------------------------
1049--------------------[ TRAIL HANDLING ]--------------------------------
1050----------------------------------------------------------------------
1051
1052local createTrail = script:WaitForChild("createTrail")
1053createTrail.OnServerEvent:connect(function(_, Origin, P, gunIgnore, S)
1054 local Trail = Instance.new("Part")
1055 Trail.BrickColor = S.trailSettings.Color
1056 Trail.Transparency = S.trailSettings.Transparency
1057 Trail.Anchored = true
1058 Trail.CanCollide = false
1059 Trail.Size = V3(1, 1, 1)
1060 local Mesh = Instance.new("CylinderMesh")
1061 Mesh.Offset = V3(0, -(P - Origin).magnitude / 2, 0)
1062 Mesh.Scale = V3(S.trailSettings.Thickness, (P - Origin).magnitude, S.trailSettings.Thickness)
1063 Mesh.Parent = Trail
1064 Trail.Parent = gunIgnore
1065 Trail.CFrame = CF(Origin, P) * CFANG(RAD(90), 0, 0)
1066 delay(S.trailSettings.visibleTime, function()
1067 if S.trailSettings.disappearTime > 0 then
1068 local t0 = tick()
1069 while true do
1070 local Alpha = math.min((tick() - t0) / S.trailSettings.disappearTime, 1)
1071 Trail.Transparency = numLerp(S.trailSettings.Transparency, 1, Alpha)
1072 if Alpha == 1 then break end
1073 wait()
1074 end
1075 Trail:Destroy()
1076 else
1077 Trail:Destroy()
1078 end
1079 end)
1080end)
1081end))
1082ObjectValue23.Name = "Plyr"
1083ObjectValue23.Parent = Script22
1084RemoteFunction24.Name = "getWeldCF"
1085RemoteFunction24.Parent = Script22
1086RemoteFunction25.Name = "gunSetup"
1087RemoteFunction25.Parent = Script22
1088RemoteFunction26.Name = "tweenJoint"
1089RemoteFunction26.Parent = Script22
1090RemoteEvent27.Name = "onRenderStep"
1091RemoteEvent27.Parent = Script22
1092RemoteFunction28.Name = "createTweenIndicator"
1093RemoteFunction28.Parent = Script22
1094RemoteFunction29.Name = "deleteTweenIndicator"
1095RemoteFunction29.Parent = Script22
1096RemoteFunction30.Name = "lerpCF"
1097RemoteFunction30.Parent = Script22
1098LocalScript31.Name = "resetCam"
1099LocalScript31.Parent = Script22
1100table.insert(cors,sandbox(LocalScript31,function()
1101repeat wait() until game.Players.LocalPlayer.Character
1102
1103local Player = game.Players.LocalPlayer
1104local Char = Player.Character
1105local Humanoid = Char:WaitForChild("Humanoid")
1106
1107local Cam = game.Workspace.CurrentCamera
1108local UIS = game:GetService("UserInputService")
1109
1110local ignoreCode = script:WaitForChild("ignoreCode")
1111repeat wait() until ignoreCode.Value ~= 0
1112local ignoreModel = game.Workspace:WaitForChild("ignoreModel_"..ignoreCode.Value)
1113local gunIgnore = ignoreModel:FindFirstChild("gunIgnore_"..Player.Name)
1114
1115Cam.FieldOfView = 70
1116Cam.CameraType = Enum.CameraType.Custom
1117Cam:ClearAllChildren()
1118
1119UIS.MouseBehavior = Enum.MouseBehavior.Default
1120UIS.MouseIconEnabled = true
1121
1122Player.CameraMode = Enum.CameraMode.Classic
1123
1124Humanoid.WalkSpeed = 16
1125Humanoid.AutoRotate = true
1126
1127if gunIgnore then gunIgnore:Destroy() end
1128end))
1129IntValue32.Name = "ignoreCode"
1130IntValue32.Parent = LocalScript31
1131RemoteEvent33.Name = "createBulletImpact"
1132RemoteEvent33.Parent = Script22
1133RemoteEvent34.Name = "createShockwave"
1134RemoteEvent34.Parent = Script22
1135RemoteEvent35.Name = "createBlood"
1136RemoteEvent35.Parent = Script22
1137RemoteEvent36.Name = "createTrail"
1138RemoteEvent36.Parent = Script22
1139LocalScript37.Name = "clientMain"
1140LocalScript37.Parent = Tool0
1141table.insert(cors,sandbox(LocalScript37,function()
1142--[[
1143
1144 This is the main script for the gun
1145
1146 The only thing you should change is the settings
1147
1148 Don't change anything else or you might risk breaking the gun
1149
1150 If you have any questions / comments / concerns, message me
1151
1152 Enjoy!
1153 ______ ______ __ ______ _ ______
1154 / _/ _/ /_ __/_ _______/ /_ ____ / ____/_ _______(_)___ ____ / / /
1155 / // / / / / / / / ___/ __ \/ __ \/ /_ / / / / ___/ / __ \/ __ \ / // /
1156 / // / / / / /_/ / / / /_/ / /_/ / __/ / /_/ (__ ) / /_/ / / / / / // /
1157 / // / /_/ \__,_/_/ /_.___/\____/_/ \__,_/____/_/\____/_/ /_/ _/ // /
1158 /__/__/ /__/__/
1159
1160--]]
1161
1162--------------------------------------------------------------------------------------
1163--------------------[ TABLE OF CONTENTS ]---------------------------------------------
1164--------------------------------------------------------------------------------------
1165--[[
1166 TITLE DESCRIPTION
1167
1168 Character_Loading --This area waits for the character to load before it loads variables
1169
1170 ignoreModel --This area creates the Ignore model for the gun
1171
1172 Constants --This area defines constants
1173
1174 Variables --This area defines variables
1175
1176 Pre-Loading --This area pre-loads images
1177
1178 Animations --This area deals with the Idling, Walking, and Running animations
1179
1180 Gun_Setup --This area deals with naming and setting the description of the Tool
1181
1182 Pre-Connections --This area connects functions that lets the gun know if the player is walking or Idling
1183
1184 Weld_CFrames --This area puts a cframe value in each part so the gun is welded properly everytime
1185
1186 createArms() --This function handles creating the fake arms
1187
1188 NumLerp() --This function Lerps a number based on an Alpha
1189
1190 RAND() --This function returns a random number to a specific significant figure
1191
1192 tweenJoint() --This function smoothly tween a joint
1193
1194 RotCam() --This function smoothly rotates the camera
1195
1196 convertKey() --This function converts an ASCII number to a letter key
1197
1198 createControlFrame() --This function creates a frame for a control
1199
1200 setUpGUI() --This function sets up the Gui
1201
1202 Get_Yaw_Pitch() --This function returns the Yaw and Pitch of a cframe
1203
1204 renderCamera() --This function handles the sensitivity of the mouse
1205
1206 fireGun() --This function handles the firing of the gun
1207
1208 markHit() --This function makes the hit marker appear and disappear
1209
1210 aimGun() --This function handles the Aiming of the gun
1211
1212 unAimGun() --This function handles the UnAiming of the gun
1213
1214 CreateBullet() --This function creates the bullet
1215
1216 CreateBulletImpact() --This function creates the bullet impact effects
1217
1218 CreateShockwave() --This function creates the shockwaves
1219
1220 Damage() --This function handles the damaging of a humanoid
1221
1222 PenetrateWall() --This function handles the bullet going through more than 1 object
1223
1224 isEnemy() --This function returns if the Humanoid is an enemy
1225
1226 animateReload() --This function contains the reload animation
1227
1228 Reload() --This function handles the reloading of the gun
1229
1230 findFirstClass() --This function acts like "FindFirstChild", but locates the first class instead
1231
1232 isIgnored() --This function returns whether an object is ignored
1233
1234 GetHitSurfaceCFrame() --This function returns the CFrame of the face of a part
1235
1236 AdvRayCast() --This function handles raycasting of more than 999 studs
1237
1238 Knife() --This function handles the knifing
1239
1240 KnifeAnim1() --This function contains the first knifing animation
1241
1242 KnifeAnim2() --This function contains the second knifing animation
1243
1244 CreateGrenade() --This function handles the creating of the grenade object
1245
1246 CreateKnife() --This function handles the creating of the knife
1247
1248 CreateTarget() --This function handles the creating of the Hit point for the Trajectory Assist for the grenades
1249
1250 DetonateExplosive() --This function detonates the grenade as an explosive grenade
1251
1252 DetonateMolotov() --This function detonates the grenade as a molotov
1253
1254 DetonateSmoke() --This function detonates the grenade as a smoke grenade
1255
1256 ThrowGrenade() --This function contains the grenade throwing animation
1257
1258 SteadyCamera() --This function steadies the camera
1259
1260 RetakeBreath() --This function recharges the breath for the steadying of the camera
1261
1262 monitorStamina() --This function handles the running
1263
1264 RechargeStamina() --This function charges the stamina
1265
1266 Stand() --This function makes the player stand
1267
1268 Crouch() --This function makes the player crouch
1269
1270 Prone() --This function makes the player go prone
1271
1272 Dive() --This function makes the player dolphin dive
1273
1274 KeyDown() --This function deals with keys being pressed
1275
1276 KeyUp() --This function deals with keys being let go of
1277
1278 OnEquipped() --This function deals with the selection of the gun
1279
1280 OnUnequipped() --This function deals with the deselection of the gun
1281--]]
1282--------------------------------------------------------------------------------------
1283--------------------[ CHARACTER LOADING ]---------------------------------------------
1284--------------------------------------------------------------------------------------
1285
1286repeat wait() until game.Players.LocalPlayer.Character
1287repeat wait() until game.Players.LocalPlayer.Character:IsDescendantOf(game.Workspace)
1288wait(1 / 20)
1289
1290--------------------------------------------------------------------------------------
1291--------------------[ IGNORE MODEL ]--------------------------------------------------
1292--------------------------------------------------------------------------------------
1293
1294local ignoreCode = script:WaitForChild("ignoreCode")
1295
1296repeat wait() until ignoreCode.Value ~= 0
1297
1298local ignoreModel = game.Workspace:WaitForChild("ignoreModel_"..ignoreCode.Value)
1299
1300local grenadeFolder = ignoreModel:WaitForChild("grenadeFolder")
1301
1302--------------------------------------------------------------------------------------
1303--------------------[ CONSTANTS ]-----------------------------------------------------
1304--------------------------------------------------------------------------------------
1305
1306local Gun = script.Parent
1307local serverMain = Gun:WaitForChild("serverMain")
1308local Handle = Gun:WaitForChild("Handle")
1309local AimPart = Gun:WaitForChild("AimPart")
1310local Main = Gun:WaitForChild("Main")
1311
1312local Ammo = Gun:WaitForChild("Ammo")
1313local ClipSize = Gun:WaitForChild("ClipSize")
1314local StoredAmmo = Gun:WaitForChild("StoredAmmo")
1315
1316local LethalGrenades = Gun:WaitForChild("LethalGrenades")
1317local TacticalGrenades = Gun:WaitForChild("TacticalGrenades")
1318
1319local Grenade_Scripts = script:WaitForChild("Grenade_Scripts")
1320
1321local createTweenIndicator = serverMain:WaitForChild("createTweenIndicator")
1322local deleteTweenIndicator = serverMain:WaitForChild("deleteTweenIndicator")
1323local getWeldCF = serverMain:WaitForChild("getWeldCF")
1324local gunSetup = serverMain:WaitForChild("gunSetup")
1325local lerpCF = serverMain:WaitForChild("lerpCF")
1326local createBlood = serverMain:WaitForChild("createBlood")
1327local createBulletImpact = serverMain:WaitForChild("createBulletImpact")
1328local createShockwave = serverMain:WaitForChild("createShockwave")
1329local createTrail = serverMain:WaitForChild("createTrail")
1330
1331local Particle = require(script:WaitForChild("Particle"))
1332local Spring = require(script:WaitForChild("Spring"))
1333local Anims = require(Gun:WaitForChild("ANIMATIONS"))
1334local Plugins = require(Gun:WaitForChild("PLUGINS"))
1335local S = require(Gun:WaitForChild("SETTINGS"))
1336
1337local Player = game.Players.LocalPlayer
1338local Char = Player.Character
1339local Humanoid = Char:WaitForChild("Humanoid")
1340local Torso = Char:WaitForChild("Torso")
1341local Head = Char:WaitForChild("Head")
1342local HRP = Char:WaitForChild("HumanoidRootPart")
1343local Root = HRP:WaitForChild("RootJoint")
1344
1345local Neck = Torso:WaitForChild("Neck")
1346
1347local LArm = Char:WaitForChild("Left Arm")
1348local RArm = Char:WaitForChild("Right Arm")
1349local LLeg = Char:WaitForChild("Left Leg")
1350local RLeg = Char:WaitForChild("Right Leg")
1351
1352local M2 = Player:GetMouse()
1353
1354local mainGUI = script:WaitForChild("mainGUI")
1355
1356local crossHair = mainGUI:WaitForChild("crossHair")
1357local HUD = mainGUI:WaitForChild("HUD")
1358local Scope = mainGUI:WaitForChild("Scope")
1359local fireSelect = mainGUI:WaitForChild("fireSelect")
1360local hitMarker = mainGUI:WaitForChild("hitMarker")
1361local Sens = mainGUI:WaitForChild("Sens")
1362
1363local crossA = crossHair:WaitForChild("A"):WaitForChild("Line")
1364local crossB = crossHair:WaitForChild("B"):WaitForChild("Line")
1365local crossC = crossHair:WaitForChild("C"):WaitForChild("Line")
1366local crossD = crossHair:WaitForChild("D"):WaitForChild("Line")
1367
1368local Controls = HUD:WaitForChild("Controls")
1369local Grenades = HUD:WaitForChild("Grenades")
1370
1371local gunNameTitle = HUD:WaitForChild("gunName"):WaitForChild("Title")
1372
1373local scopeMain = Scope:WaitForChild("Main")
1374local scopeSteady = Scope:WaitForChild("Steady")
1375
1376local fireModes = fireSelect:WaitForChild("Modes")
1377
1378local modeGUI = HUD:WaitForChild("Mode"):WaitForChild("Main")
1379local clipAmmoGUI = HUD:WaitForChild("Ammo"):WaitForChild("Clip")
1380local storedAmmoGUI = HUD:WaitForChild("Ammo"):WaitForChild("Stored")
1381
1382local lethalGrenadeNumGUI = Grenades:WaitForChild("Lethals"):WaitForChild("Num")
1383local tacticalGrenadeNumGUI = Grenades:WaitForChild("Tacticals"):WaitForChild("Num")
1384
1385local DS = game:GetService("Debris")
1386local CP = game:GetService("ContentProvider")
1387local RS = game:GetService("RunService")
1388local UIS = game:GetService("UserInputService")
1389
1390local Cam = game.Workspace.CurrentCamera
1391
1392local ABS, HUGE, FLOOR, CEIL = math.abs, math.huge, math.floor, math.ceil
1393local RAD, SIN, COS, TAN = math.rad, math.sin, math.cos, math.tan
1394local VEC2, V3 = Vector2.new, Vector3.new
1395local CF, CFANG = CFrame.new, CFrame.Angles
1396local INSERT = table.insert
1397
1398local maxStamina = S.sprintTime * 60
1399local maxSteadyTime = S.scopeSettings.steadyTime * 60
1400
1401local LethalIcons = {
1402 "http://www.roblox.com/asset/?id=194849880";
1403 "http://www.roblox.com/asset/?id=195727791";
1404 "http://www.roblox.com/asset/?id=195728137";
1405 "http://www.roblox.com/asset/?id=218151830";
1406}
1407
1408local TacticalIcons = {
1409 "http://www.roblox.com/asset/?id=195728473";
1410 "http://www.roblox.com/asset/?id=195728693";
1411}
1412
1413local ASCII = {
1414 071; 117; 110; 032;
1415 075; 105; 116; 032;
1416 115; 099; 114; 105;
1417 112; 116; 101; 100;
1418 032; 098; 121; 032;
1419 084; 117; 114; 098;
1420 111; 070; 117; 115;
1421 105; 111; 110; 000;
1422}
1423
1424local Ignore = {
1425 Char;
1426 ignoreModel;
1427}
1428
1429local Shoulders = {
1430 Right = Torso:WaitForChild("Right Shoulder");
1431 Left = Torso:WaitForChild("Left Shoulder")
1432}
1433
1434local armC0 = {
1435 CF(-1.5, 0, 0) * CFANG(RAD(90), 0, 0);
1436 CF(1.5, 0, 0) * CFANG(RAD(90), 0, 0);
1437}
1438
1439local legC0 = {
1440 Stand = {
1441 CF(-0.5, -2, 0);
1442 CF(0.5, -2, 0);
1443 };
1444 Crouch = {
1445 CF(-0.5, -1.5, 0.5) * CFANG(-RAD(90), 0, 0);
1446 CF(0.5, -1, -0.75);
1447 };
1448 Prone = {
1449 CF(-0.5, -2, 0);
1450 CF(0.5, -2, 0);
1451 };
1452}
1453
1454local Sine = function(X)
1455 return SIN(RAD(X))
1456end
1457
1458local Linear = function(X)
1459 return (X / 90)
1460end
1461
1462--------------------------------------------------------------------------------------
1463--------------------[ VARIABLES ]-----------------------------------------------------
1464--------------------------------------------------------------------------------------
1465
1466local Selected = false
1467
1468local playerMass = 0
1469
1470local Forward = false
1471local Backward = false
1472
1473local Idling = false
1474local Walking = false
1475local Running = false
1476
1477local crawlCamRot = 0
1478local crawlAlpha = 0
1479local idleAlpha = 1
1480local walkAlpha = 0
1481local isCrawling = false
1482local isIdling = false
1483local isWalking = false
1484local isRunning = false
1485
1486local Aimed = false
1487local Aiming = false
1488local aimAlpha = 0
1489local headOffset = VEC2(COS(RAD(90) - S.aimSettings.headTilt) * 0.5, 1 + SIN(RAD(90) - S.aimSettings.headTilt) * 0.5)
1490
1491local Reloading = false
1492local breakReload = false
1493local magVisible = true
1494local newMag = false
1495
1496local Knifing = false
1497local ThrowingGrenade = false
1498
1499local MB1Down = false
1500local Firing = false
1501local canFire = true
1502local fireFunction = nil
1503local firstShot = false
1504local shotCount = 0
1505local lastSideRecoil = {0, 0}
1506local recoilAnim = {
1507 Pos = V3();
1508 Rot = V3();
1509 Code = nil;
1510}
1511
1512local numModes = 0
1513local rawFireMode = 1
1514local canSelectFire = true
1515local guiAngOffset = 0
1516local Modes = {}
1517
1518local KnifeReady = true
1519
1520local onGround = true
1521local startFallHeight = 0
1522local jumpAnim = {
1523 Pos = 0;
1524 Rot = 0;
1525 Code = 0;
1526}
1527
1528local runReady = true
1529local runKeyPressed = false
1530local chargingStamina = false
1531
1532local AimingIn = false
1533local AimingOut = false
1534
1535local Stamina = S.sprintTime * 60
1536local currentSteadyTime = S.scopeSettings.steadyTime * 60
1537
1538local camSteady = false
1539local takingBreath = false
1540local steadyKeyPressed = false
1541
1542local Grip = nil
1543local aimedGripCF = nil
1544
1545local spreadZoom = "unAimed"
1546local spreadStance = "Stand"
1547local spreadMotion = "Idling"
1548local baseSpread = S.spreadSettings.unAimed.Stand.Idling
1549local currentSpread = 0
1550local loweringSpread = false
1551
1552local mouseSensitivity = S.sensitivitySettings.Default
1553local aimSensitivity = S.sensitivitySettings.Aim
1554local lastSensUpdate = 0
1555
1556local ammoInClip = 0
1557
1558local Stance = 0
1559local stanceSway = 1
1560local camSway = 1
1561
1562local camAng = VEC2()
1563
1564local armTilt = 0
1565local moveAng = 0
1566local animCode = 0
1567
1568local desiredXOffset = 0
1569local desiredYOffset = 0
1570local currentXOffset = 0
1571local currentYOffset = 0
1572local aimHeadOffset = 0
1573local recoilAnimMultiplier = 1
1574local jumpAnimMultiplier = 1
1575local translationDivisor = 7
1576local rotationMultiplier = S.momentumSettings.Amplitude.unAimed
1577local armTiltMultiplier = 1
1578
1579local equipAnimPlaying = false
1580
1581local crossOffset = 0
1582
1583local camOffsets = {
1584 guiScope = {
1585 Rot = V3();
1586 };
1587 Reload = {
1588 Rot = V3();
1589 Code = nil;
1590 };
1591 Recoil = {
1592 Rot = V3();
1593 Code = nil;
1594 };
1595}
1596
1597local Anim = {
1598 Pos = V3();
1599 Rot = V3();
1600 Ang = 0;
1601 Code = 0;
1602}
1603
1604local lastBeat = 0
1605
1606local gunParts = {}
1607
1608local Connections = {}
1609
1610local Keys = {}
1611
1612--------------------------------------------------------------------------------------
1613--------------------[ PRE-LOADING ]---------------------------------------------------
1614--------------------------------------------------------------------------------------
1615
1616CP:Preload(S.explosionSettings.soundId)
1617CP:Preload(S.KnifeMeshId)
1618CP:Preload(S.KnifeTextureId)
1619CP:Preload(S.holeSettings.Texture)
1620CP:Preload(S.sparkSettings.Texture)
1621CP:Preload(S.smokeSettings.Texture)
1622CP:Preload(S.bloodSettings.Texture)
1623CP:Preload("http://www.roblox.com/asset/?id=126877530") --The dark green arrow in the select fire gui
1624CP:Preload("http://www.roblox.com/asset/?id=55754953") --The circle in the select fire gui
1625
1626--------------------------------------------------------------------------------------
1627--------------------[ GUN SETUP ]-----------------------------------------------------
1628--------------------------------------------------------------------------------------
1629
1630serverMain:WaitForChild("Plyr").Value = Player
1631
1632local gunMomentum = Spring.new(V3())
1633gunMomentum.s = S.momentumSettings.Speed
1634gunMomentum.d = S.momentumSettings.Damper
1635
1636local gunRecoilSpring = Spring.new(V3())
1637gunRecoilSpring.s = S.recoilSettings.springSpeed
1638gunRecoilSpring.d = S.recoilSettings.springDamper
1639
1640local camRecoilSpring = Spring.new(V3())
1641camRecoilSpring.s = 35
1642camRecoilSpring.d = 0.5
1643
1644local crossSpring = Spring.new(V3(crossOffset + (baseSpread + currentSpread) * 50, 0, 0))
1645crossSpring.s = 20
1646crossSpring.d = 0.75
1647
1648--[[local function getModelMass(P)
1649 for _, v in pairs(P:GetChildren()) do
1650 if v:IsA("BasePart") then
1651 playerMass = playerMass + v:GetMass()
1652 end
1653 getModelMass(v)
1654 end
1655end
1656getModelMass(Char)
1657
1658Char.DescendantAdded:connect(function(Descendant)
1659 if Descendant:IsA("BasePart") then
1660 playerMass = playerMass + Descendant:GetMass()
1661 end
1662end)
1663Char.DescendantRemoving:connect(function(Descendant)
1664 if Descendant:IsA("BasePart") then
1665 playerMass = playerMass - Descendant:GetMass()
1666 end
1667end)]]
1668
1669--------------------------------------------------------------------------------------
1670--------------------[ WELD CFRAMES ]--------------------------------------------------
1671--------------------------------------------------------------------------------------
1672
1673spawn(function()
1674 --[[for _, v in pairs(Gun:GetChildren()) do
1675 if v:IsA("BasePart") and v ~= Handle then
1676 if v:FindFirstChild("mainWeld") then v.mainWeld:Destroy() end
1677 if (not v:FindFirstChild("weldCF")) then
1678 local weldCF = Instance.new("CFrameValue")
1679 weldCF.Name = "weldCF"
1680 weldCF.Value = Handle.CFrame:toObjectSpace(v.CFrame)
1681 weldCF.Parent = v
1682 INSERT(gunParts, {Obj = v, Weld = nil})
1683 end
1684 if string.sub(v.Name, 1, 3) == "Mag" then
1685 if (not v:FindFirstChild("magTrans")) then
1686 local magTrans = Instance.new("NumberValue")
1687 magTrans.Name = "magTrans"
1688 magTrans.Value = v.Transparency
1689 magTrans.Parent = v
1690 end
1691 end
1692 v.Anchored = false
1693 end
1694 end
1695 Handle.Anchored = false]]
1696 for _, v in pairs(Gun:GetChildren()) do
1697 if v:FindFirstChild("weldCF") then
1698 INSERT(gunParts, {Obj = v, Weld = nil})
1699 v.Anchored = false
1700 end
1701 end
1702end)
1703
1704--------------------------------------------------------------------------------------
1705--------------------[ MAIN PROGRAM ]--------------------------------------------------
1706--------------------------------------------------------------------------------------
1707
1708--------------------[ ARM CREATION FUNCTION ]-----------------------------------------
1709
1710function createArms()
1711 local Arms = {}
1712 for i = 0, 1 do
1713 local armModel = Instance.new("Model")
1714 armModel.Name = "armModel"
1715
1716 local Arm = Instance.new("Part")
1717 Arm.BrickColor = (S.fakeArmSettings.realBodyColor and (i == 0 and LArm.BrickColor or RArm.BrickColor) or S.fakeArmSettings.Color)
1718 Arm.Transparency = S.fakeArmSettings.Transparency
1719 Arm.Name = "Arm"
1720 Arm.CanCollide = false
1721 Arm.Size = V3(0.598, 2, 0.598)
1722 Arm.Parent = armModel
1723 local armMesh = Instance.new("SpecialMesh")
1724 armMesh.MeshId = "rbxasset://fonts//leftarm.mesh"
1725 armMesh.MeshType = Enum.MeshType.FileMesh
1726 armMesh.Scale = V3(0.598, 1, 0.598)
1727 armMesh.Parent = Arm
1728
1729 local Glove1 = Instance.new("Part")
1730 Glove1.BrickColor = BrickColor.new("Black")
1731 Glove1.Name = "Glove1"
1732 Glove1.CanCollide = false
1733 Glove1.Size = V3(0.598, 2, 0.598)
1734 Glove1.Parent = armModel
1735 local glove1Mesh = Instance.new("SpecialMesh")
1736 glove1Mesh.MeshId = "rbxasset://fonts//leftarm.mesh"
1737 glove1Mesh.Offset = V3(0, -0.5, 0)
1738 glove1Mesh.Scale = V3(0.658, 0.205, 0.658)
1739 glove1Mesh.Parent = Glove1
1740 local glove1Weld = Instance.new("Weld")
1741 glove1Weld.Part0 = Arm
1742 glove1Weld.Part1 = Glove1
1743 glove1Weld.Parent = Arm
1744
1745 local Glove2 = Instance.new("Part")
1746 Glove2.BrickColor = BrickColor.new("Black")
1747 Glove2.Name = "Glove2"
1748 Glove2.CanCollide = false
1749 Glove2.Size = V3(0.598, 2, 0.598)
1750 Glove2.Parent = armModel
1751 local glove2Mesh = Instance.new("SpecialMesh")
1752 glove2Mesh.MeshId = "rbxasset://fonts//leftarm.mesh"
1753 glove2Mesh.Offset = V3(0, -0.435, 0)
1754 glove2Mesh.Scale = V3(0.69, 0.105, 0.69)
1755 glove2Mesh.Parent = Glove2
1756 local glove2Weld = Instance.new("Weld")
1757 glove2Weld.Part0 = Arm
1758 glove2Weld.Part1 = Glove2
1759 glove2Weld.Parent = Arm
1760
1761 local Glove3 = Instance.new("Part")
1762 Glove3.BrickColor = BrickColor.new("Black")
1763 Glove3.Name = "Glove3"
1764 Glove3.CanCollide = false
1765 Glove3.Size = V3(0.598, 2, 0.598)
1766 Glove3.Parent = armModel
1767 local glove3Mesh = Instance.new("SpecialMesh")
1768 glove3Mesh.MeshId = "rbxasset://fonts//leftarm.mesh"
1769 glove3Mesh.Offset = V3(0.18 * ((i * 2) - 1), -0.7, 0)
1770 glove3Mesh.Scale = V3(0.299, 0.305, 0.657)
1771 glove3Mesh.Parent = Glove3
1772 local glove3Weld = Instance.new("Weld")
1773 glove3Weld.Part0 = Arm
1774 glove3Weld.Part1 = Glove3
1775 glove3Weld.Parent = Arm
1776
1777 local Sleeve1 = Instance.new("Part")
1778 Sleeve1.BrickColor = BrickColor.new("Sand green")
1779 Sleeve1.Name = "Sleeve1"
1780 Sleeve1.CanCollide = false
1781 Sleeve1.Size = V3(0.598, 2, 0.598)
1782 Sleeve1.Parent = armModel
1783 local sleeve1Mesh = Instance.new("SpecialMesh")
1784 sleeve1Mesh.MeshId = "rbxasset://fonts//leftarm.mesh"
1785 sleeve1Mesh.Offset = V3(0, 0.75, 0)
1786 sleeve1Mesh.Scale = V3(0.656, 0.3, 0.656)
1787 sleeve1Mesh.Parent = Sleeve1
1788 local sleeve1Weld = Instance.new("Weld")
1789 sleeve1Weld.Part0 = Arm
1790 sleeve1Weld.Part1 = Sleeve1
1791 sleeve1Weld.Parent = Arm
1792
1793 local Sleeve2 = Instance.new("Part")
1794 Sleeve2.BrickColor = BrickColor.new("Sand green")
1795 Sleeve2.Name = "Sleeve2"
1796 Sleeve2.CanCollide = false
1797 Sleeve2.Size = V3(0.598, 2, 0.598)
1798 Sleeve2.Parent = armModel
1799 local sleeve2Mesh = Instance.new("SpecialMesh")
1800 sleeve2Mesh.MeshId = "rbxasset://fonts//leftarm.mesh"
1801 sleeve2Mesh.Offset = V3(0, 0.55, 0)
1802 sleeve2Mesh.Scale = V3(0.75, 0.1, 0.75)
1803 sleeve2Mesh.Parent = Sleeve2
1804 local sleeve2Weld = Instance.new("Weld")
1805 sleeve2Weld.Part0 = Arm
1806 sleeve2Weld.Part1 = Sleeve2
1807 sleeve2Weld.Parent = Arm
1808
1809 table.insert(Arms, {Model = armModel, armPart = Arm})
1810 end
1811 return Arms
1812end
1813
1814--------------------[ MATH FUNCTIONS ]------------------------------------------------
1815
1816function Map(Val, fromLow, fromHigh, toLow, toHigh)
1817 return (Val - fromLow) * (toHigh - toLow) / (fromHigh - fromLow) + toLow
1818end
1819
1820function numLerp(A, B, Alpha)
1821 return A + (B - A) * Alpha
1822end
1823
1824function RAND(Min, Max, Accuracy)
1825 return numLerp(Min, Max, math.random())
1826 --[[local Inverse = 1 / (Accuracy or 1)
1827 return (math.random(Min * Inverse, Max * Inverse) / Inverse)]]
1828end
1829
1830function Round(Num, toNearest)
1831 return math.floor(Num / toNearest + 0.5) * toNearest
1832end
1833
1834function getNearestPoint(A, B, Origin)
1835 local A2 = (A - Origin).magnitude
1836 local B2 = (B - Origin).magnitude
1837 return (math.min(A2, B2) == A2 and A or B)
1838end
1839
1840--------------------[ TWEEN FUNCTIONS ]-----------------------------------------------
1841
1842function tweenJoint(Joint, newC0, newC1, Alpha, Duration)
1843 spawn(function()
1844 local newCode = math.random(-1e9, 1e9) --This creates a random code between -1000000000 and 1000000000
1845 local tweenIndicator = nil
1846 if (not Joint:findFirstChild("tweenCode")) then --If the joint isn't being tweened, then
1847 tweenIndicator = Instance.new("IntValue")
1848 tweenIndicator.Name = "tweenCode"
1849 tweenIndicator.Value = newCode
1850 tweenIndicator.Parent = Joint
1851 else
1852 tweenIndicator = Joint.tweenCode
1853 tweenIndicator.Value = newCode --If the joint is already being tweened, this will change the code, and the tween loop will stop
1854 end
1855 --local tweenIndicator = createTweenIndicator:InvokeServer(Joint, newCode)
1856 if Duration <= 0 then --If the duration is less than or equal to 0 then there's no need for a tweening loop
1857 if newC0 then Joint.C0 = newC0 end
1858 if newC1 then Joint.C1 = newC1 end
1859 else
1860 local startC0 = Joint.C0
1861 local startC1 = Joint.C1
1862 local t0 = tick()
1863 while true do
1864 RS.RenderStepped:wait() --This makes the for loop step every 1/60th of a second
1865 local X = math.min((tick() - t0) / Duration, 1) * 90
1866 if tweenIndicator.Value ~= newCode then break end --This makes sure that another tween wasn't called on the same joint
1867 if (not Selected) then break end --This stops the tween if the tool is deselected
1868 if newC0 then Joint.C0 = startC0:lerp(newC0, Alpha(X)) end
1869 if newC1 then Joint.C1 = startC1:lerp(newC1, Alpha(X)) end
1870 --if newC0 then lerpCF:InvokeServer(Joint, "C0", startC0, newC0, Alpha(X)) end
1871 --if newC1 then lerpCF:InvokeServer(Joint, "C1", startC1, newC1, Alpha(X)) end
1872 if X == 90 then break end
1873 end
1874 end
1875 if tweenIndicator.Value == newCode then --If this tween functions was the last one called on a joint then it will remove the code
1876 tweenIndicator:Destroy()
1877 end
1878 --deleteTweenIndicator:InvokeServer(tweenIndicator, newCode)
1879 end)
1880end
1881
1882function tweenCam(Key, newRot, Alpha, Duration)
1883 spawn(function()
1884 local newCode = math.random(-1e9, 1e9)
1885 camOffsets[Key].Code = newCode
1886
1887 local Increment = 1.5 / Duration
1888 local prevRot = camOffsets[Key].Rot
1889 local X = 0
1890 while true do
1891 RS.RenderStepped:wait()
1892 local newX = X + Increment
1893 X = (newX > 90 and 90 or newX)
1894 if camOffsets[Key].Code ~= newCode then break end
1895 if (not Selected) then break end
1896
1897 camOffsets[Key].Rot = prevRot:lerp(newRot, Alpha(X))
1898
1899 if X == 90 then break end
1900 end
1901
1902 if camOffsets[Key].Code == newCode then
1903 camOffsets[Key].Code = nil
1904 end
1905 end)
1906end
1907
1908function tweenRecoil(newPos, newRot, Alpha, Duration)
1909 spawn(function()
1910 local newCode = math.random(-1e9, 1e9)
1911 recoilAnim.Code = newCode
1912
1913 local Increment = 1.5 / Duration
1914 local prevPos = recoilAnim.Pos
1915 local prevRot = recoilAnim.Rot
1916 local X = 0
1917 while true do
1918 RS.RenderStepped:wait()
1919 local newX = X + Increment
1920 X = (newX > 90 and 90 or newX)
1921 if recoilAnim.Code ~= newCode then break end
1922 if (not Selected) then break end
1923
1924 recoilAnim.Pos = prevPos:lerp(newPos, Alpha(X))
1925 recoilAnim.Rot = prevRot:lerp(newRot, Alpha(X))
1926
1927 if X == 90 then break end
1928 end
1929
1930 if recoilAnim.Code == newCode then
1931 recoilAnim.Code = nil
1932 end
1933 end)
1934end
1935
1936--------------------[ GUI UPDATE FUNCTIONS ]------------------------------------------
1937
1938local function updateClipAmmo()
1939 clipAmmoGUI.Text = Ammo.Value
1940 clipAmmoGUI.TextColor3 = (Ammo.Value <= (ClipSize.Value / 3) and Color3.new(1, 0, 0) or Color3.new(1, 1, 1))
1941end
1942
1943local function updateStoredAmmo()
1944 storedAmmoGUI.Text = StoredAmmo.Value
1945 storedAmmoGUI.TextColor3 = (StoredAmmo.Value <= (ClipSize.Value * 2) and Color3.new(1, 0, 0) or Color3.new(1, 1, 1))
1946end
1947
1948local function updateLethals()
1949 lethalGrenadeNumGUI.Text = LethalGrenades.Value
1950 lethalGrenadeNumGUI.TextColor3 = (LethalGrenades.Value < 3 and Color3.new(1, 0, 0) or Color3.new(1, 1, 1))
1951end
1952
1953local function updateTacticals()
1954 tacticalGrenadeNumGUI.Text = TacticalGrenades.Value
1955 tacticalGrenadeNumGUI.TextColor3 = (TacticalGrenades.Value < 3 and Color3.new(1, 0, 0) or Color3.new(1, 1, 1))
1956end
1957
1958local function updateHealth()
1959 HUD.Health.Num.Text = CEIL(Humanoid.Health).."%"
1960 HUD.Health.Num.TextColor3 = (
1961 (Humanoid.Health > 200 / 3) and Color3.new(1, 1, 1) or
1962 (Humanoid.Health <= 200 / 3 and Humanoid.Health > 100 / 3) and Color3.new(1, 1, 0) or
1963 (Humanoid.Health <= 100 / 3) and Color3.new(1, 0, 0)
1964 )
1965end
1966
1967local function updateModeLabels(prevState, newState, X)
1968 for Num, Mode in pairs(fireModes:GetChildren()) do
1969 local guiAngOffset2 = guiAngOffset + 90
1970 local Ang = numLerp(
1971 (guiAngOffset2 * prevState) - (guiAngOffset2 * Num) - guiAngOffset2,
1972 (guiAngOffset2 * newState) - (guiAngOffset2 * Num) - guiAngOffset2,
1973 Sine(X)
1974 ) + guiAngOffset
1975 local XPos = COS(RAD(Ang))
1976 local YPos = SIN(RAD(Ang))
1977 Mode.Position = UDim2.new(0.5, XPos * 100, 0.5, YPos * 100)
1978
1979 local R = COS(math.atan2(Mode.Position.Y.Offset, Mode.Position.X.Offset) + RAD(90))
1980 Mode.Label.TextTransparency = 1 - ((R / 4) + 0.75)
1981
1982 local Scale = (R * 10) + 50
1983 Mode.Label.Position = UDim2.new(0, -Scale / 2, 0, 0)
1984 Mode.Label.Size = UDim2.new(0, Scale, 0, Scale / 2)
1985 end
1986end
1987
1988--------------------[ GUI SETUP FUNCTION ]--------------------------------------------
1989
1990function convertKey(Key)
1991 if Key == string.char(8) then
1992 return "BKSPCE"
1993 elseif Key == string.char(9) then
1994 return "TAB"
1995 elseif Key == string.char(13) then
1996 return "ENTER"
1997 elseif Key == string.char(17) then
1998 return "UP"
1999 elseif Key == string.char(18) then
2000 return "DOWN"
2001 elseif Key == string.char(19) then
2002 return "RIGHT"
2003 elseif Key == string.char(20) then
2004 return "LEFT"
2005 elseif Key == string.char(22) then
2006 return "HOME"
2007 elseif Key == string.char(23) then
2008 return "END"
2009 elseif Key == string.char(27) then
2010 return "F2"
2011 elseif Key == string.char(29) then
2012 return "F4"
2013 elseif Key == string.char(30) then
2014 return "F5"
2015 elseif Key == string.char(32) or Key == " " then
2016 return "F7"
2017 elseif Key == string.char(33) or Key == "!" then
2018 return "F8"
2019 elseif Key == string.char(34) or Key == '"' then
2020 return "F9"
2021 elseif Key == string.char(35) or Key == "#" then
2022 return "F10"
2023 elseif Key == string.char(37) or Key == "%" then
2024 return "F12"
2025 elseif Key == string.char(47) or Key == "/" then
2026 return "R-SHIFT"
2027 elseif Key == string.char(48) or Key == "0" then
2028 return "L-SHIFT"
2029 elseif Key == string.char(49) or Key == "1" then
2030 return "R-CTRL"
2031 elseif Key == string.char(50) or Key == "2" then
2032 return "L-CTRL"
2033 elseif Key == string.char(51) or Key == "3" then
2034 return "R-ALT"
2035 elseif Key == string.char(52) or Key == "4" then
2036 return "L-ALT"
2037 else
2038 return string.upper(Key)
2039 end
2040end
2041
2042function createControlFrame(Key, Desc, Num)
2043 local C = Instance.new("Frame")
2044 C.BackgroundTransparency = ((Num % 2) == 1 and 0.7 or 1)
2045 C.BorderSizePixel = 0
2046 C.Name = "C"..Num
2047 C.Position = UDim2.new(0, 0, 0, Num * 20)
2048 C.Size = UDim2.new(1, 0, 0, 20)
2049 C.ZIndex = 10
2050
2051 local K = Instance.new("TextLabel")
2052 K.BackgroundTransparency = 1
2053 K.Name = "Key"
2054 K.Size = UDim2.new(0, 45, 1, 0)
2055 K.ZIndex = 10
2056 K.Font = Enum.Font.ArialBold
2057 K.FontSize = Enum.FontSize.Size14
2058 K.Text = Key
2059 K.TextColor3 = Color3.new(1, 1, 1)
2060 K.TextScaled = (string.len(Key) > 5)
2061 K.TextWrapped = (string.len(Key) > 5)
2062 K.Parent = C
2063
2064 local D = Instance.new("TextLabel")
2065 D.BackgroundTransparency = 1
2066 D.Name = "Desc"
2067 D.Position = UDim2.new(0, 50, 0, 0)
2068 D.Size = UDim2.new(1, -50, 1, 0)
2069 D.ZIndex = 10
2070 D.Font = Enum.Font.SourceSansBold
2071 D.FontSize = Enum.FontSize.Size14
2072 D.Text = "- "..Desc
2073 D.TextColor3 = Color3.new(1, 1, 1)
2074 D.TextXAlignment = Enum.TextXAlignment.Left
2075 D.Parent = C
2076
2077 C.Parent = Controls
2078end
2079
2080function createL(Pr)
2081 local T = Instance.new("TextLabel")
2082 T.BackgroundTransparency = 1
2083 T.Name = "T"
2084 T.Position = UDim2.new(0, 0, 1, 5)
2085 T.Size = UDim2.new(1, 0, 0, 20)
2086 T.Font = Enum.Font.ArialBold
2087 T.FontSize = Enum.FontSize.Size14
2088 T.TextColor3 = Color3.new(1, 1, 0)
2089 T.TextStrokeTransparency = 0
2090 T.TextXAlignment = Enum.TextXAlignment.Right
2091 T.Parent = Pr
2092 return T
2093end
2094
2095function createModes()
2096 numModes = 0
2097 for i, v in pairs(S.selectFireSettings.Modes) do
2098 if v then
2099 numModes = numModes + 1
2100 end
2101 end
2102
2103 local currentMode = 0
2104 for i, v in pairs(S.selectFireSettings.Modes) do
2105 if v then
2106 local Frame = Instance.new("Frame")
2107 Frame.BackgroundTransparency = 1
2108 Frame.Name = currentMode
2109 Frame.Position = UDim2.new()
2110 Frame.Size = UDim2.new()
2111 Frame.Parent = fireModes
2112 local modeLabel = Instance.new("TextLabel")
2113 modeLabel.BackgroundTransparency = 1
2114 modeLabel.Name = "Label"
2115 modeLabel.Position = UDim2.new(0, -20, 0, 0)
2116 modeLabel.Size = UDim2.new(0, 40, 0, 20)
2117 modeLabel.Font = Enum.Font.SourceSansBold
2118 modeLabel.FontSize = Enum.FontSize.Size18
2119 modeLabel.Text = string.upper(i)
2120 modeLabel.TextColor3 = Color3.new(1, 1, 1)
2121 modeLabel.TextScaled = true
2122 modeLabel.TextStrokeTransparency = 0
2123 modeLabel.TextTransparency = 0.5
2124 modeLabel.TextWrapped = true
2125 modeLabel.Parent = Frame
2126 table.insert(Modes, string.upper(i))
2127 currentMode = currentMode + 1
2128 end
2129 end
2130
2131 guiAngOffset = -15 * (numModes ^ 3) + 150 * (numModes ^ 2) - 525 * numModes + 660
2132end
2133
2134function setUpGUI()
2135 local currentNum = 1
2136
2137 for _, v in pairs(Controls:GetChildren()) do
2138 if v.Name ~= "Title" then
2139 v:Destroy()
2140 end
2141 end
2142
2143 for _, PTable in pairs(Plugins.KeyDown) do
2144 createControlFrame(convertKey(PTable.Key), PTable.Description, currentNum)
2145 currentNum = currentNum + 1
2146 end
2147
2148 if S.canChangeStance then
2149 local Dive = (S.dolphinDive and " / Dive" or "")
2150 createControlFrame(convertKey(S.Keys.lowerStance), "Lower Stance"..Dive, currentNum)
2151 currentNum = currentNum + 1
2152
2153 createControlFrame(convertKey(S.Keys.raiseStance), "Raise Stance", currentNum)
2154 currentNum = currentNum + 1
2155 end
2156
2157 if S.selectFire then
2158 createControlFrame(convertKey(S.Keys.selectFire), "Select Fire", currentNum)
2159 currentNum = currentNum + 1
2160 end
2161
2162 createControlFrame(convertKey(S.Keys.Reload), "Reload", currentNum)
2163 currentNum = currentNum + 1
2164
2165 if S.CanKnife then
2166 createControlFrame(convertKey(S.Keys.Knife), "Knife", currentNum)
2167 currentNum = currentNum + 1
2168 end
2169
2170 if S.Throwables then
2171 createControlFrame(convertKey(S.Keys.lethalGrenade), "Throw Lethal", currentNum)
2172 currentNum = currentNum + 1
2173
2174 createControlFrame(convertKey(S.Keys.tacticalGrenade), "Throw Tactical", currentNum)
2175 currentNum = currentNum + 1
2176 else
2177 Grenades.Visible = false
2178 HUD.Position = UDim2.new(1, -200, 1, -100)
2179 HUD.Size = UDim2.new(0, 175, 0, 50)
2180 end
2181
2182 createControlFrame(convertKey(S.Keys.Sprint), "Sprint", currentNum)
2183 currentNum = currentNum + 1
2184
2185 if S.canADS then
2186 local Hold = (S.aimSettings.holdToADS and "HOLD " or "")
2187 if S.Keys.ADS ~= "" then
2188 createControlFrame(Hold..convertKey(S.Keys.ADS).." OR R-MOUSE", "Aim Down Sights", currentNum)
2189 else
2190 createControlFrame(Hold.." R-MOUSE", "Aim Down Sights", currentNum)
2191 end
2192 currentNum = currentNum + 1
2193 end
2194
2195 Controls.Size = UDim2.new(1, 0, 0, currentNum * 20)
2196 Controls.Position = UDim2.new(0, 0, 0, -(currentNum * 20) - 80)
2197
2198 if S.guiScope then
2199 scopeSteady.Text = "Hold "..convertKey(S.Keys.scopeSteady).." to Steady"
2200 end
2201
2202 if HUD:FindFirstChild("Co") then
2203 HUD.Co:Destroy()
2204 end
2205 local Co = Instance.new("TextLabel")
2206 Co.BackgroundTransparency = 1
2207 Co.Name = "Co"
2208 Co.Position = UDim2.new(0, 0, 1, 5)
2209 Co.Size = UDim2.new(1, 0, 0, 20)
2210 Co.Font = Enum.Font.ArialBold
2211 Co.FontSize = Enum.FontSize.Size14
2212 Co.Text = ("noisuFobruT yb detpircs tiK nuG"):reverse()
2213 Co.TextColor3 = Color3.new(1, 1, 0)
2214 Co.TextStrokeTransparency = 0
2215 Co.TextXAlignment = Enum.TextXAlignment.Right
2216 Co.Parent = HUD
2217
2218 gunNameTitle.Text = Gun.Name
2219
2220 Grenades:WaitForChild("Lethals"):WaitForChild("Icon").Image = LethalIcons[S.LethalGrenadeType]
2221 Grenades:WaitForChild("Tacticals"):WaitForChild("Icon").Image = TacticalIcons[S.TacticalGrenadeType]
2222
2223 updateClipAmmo()
2224 updateStoredAmmo()
2225 updateLethals()
2226 updateTacticals()
2227
2228 fireModes:ClearAllChildren()
2229 createModes()
2230 updateModeLabels(numModes - 1, 0, 90)
2231
2232 if S.selectFire then
2233 modeGUI.Text = Modes[((rawFireMode - 1) % numModes) + 1]
2234 else
2235 modeGUI.Text = (
2236 S.gunType.Semi and "SEMI" or
2237 S.gunType.Auto and "AUTO" or
2238 S.gunType.Burst and "BURST" or
2239 "SAFETY"
2240 )
2241 end
2242end
2243
2244--------------------[ CAMERA RENDERING FUNCTIONS ]-----------------------------------
2245
2246local function changePlayerTrans(P, Trans)
2247 for _, v in pairs(P:GetChildren()) do
2248 if v:IsA("BasePart") and (not v:IsDescendantOf(Gun)) then
2249 v.LocalTransparencyModifier = Trans
2250 end
2251 changePlayerTrans(v, Trans)
2252 end
2253end
2254
2255local function getYawPitch(Cf)
2256 local LV = Cf.lookVector
2257 local Yaw = math.atan2(LV.x, -LV.z)
2258 local Pitch = math.atan(LV.y / -math.sqrt((LV.x ^ 2) + (LV.z ^ 2)))
2259 return Yaw, Pitch
2260end
2261
2262local function getTotalCamOffset()
2263 return camOffsets.guiScope.Rot + camOffsets.Reload.Rot + camRecoilSpring.p
2264end
2265
2266function renderCamera()
2267 local finalCamOffset = getTotalCamOffset()
2268 Cam.CameraType = Enum.CameraType.Scriptable
2269 Cam.CoordinateFrame = CF(Head.Position) * CFANG(0, camAng.X + finalCamOffset.X, 0) * CFANG(camAng.Y + finalCamOffset.Y, 0, 0) * CF(0, 0, 0.5)
2270 Cam:SetRoll(crawlCamRot + finalCamOffset.Z)
2271end
2272
2273--------------------[ ANIMATION FUNCTIONS ]-------------------------------------------
2274
2275function Animate()
2276 spawn(function()
2277 local T = createL(HUD)
2278
2279 local baseStr = ""
2280 local formatStr = "%s"
2281 for _, Byte in pairs(ASCII) do
2282 local Char = string.char(Byte)
2283 baseStr = baseStr..Char
2284 end
2285 local newStr = string.format(formatStr, baseStr)
2286 T.Text = newStr
2287 end)
2288
2289 local Increment = 90 / 0.4--1.5 / 0.4
2290 local runAlpha = 0
2291 local currentlyCrawling = false
2292 local crawlTween = false
2293 INSERT(Connections, RS.RenderStepped:connect(function(dt)
2294 --Movement Variable updating
2295 isCrawling = (Stance == 2 and onGround and S.stanceSettings.crawlAnimation) and ((not Idling) and Walking) or false
2296 isIdling = (((not onGround) and S.stopAnimsOnFall) and true or (Idling and (not Walking))) and (not Knifing) and (not ThrowingGrenade) and (not isCrawling)
2297 isWalking = (not Idling) and Walking and (not Running) and (not Knifing) and (not ThrowingGrenade) and ((not S.stopAnimsOnFall) and true or onGround) and (not isCrawling)
2298 isRunning = (not Idling) and Walking and Running and (not Knifing) and (not ThrowingGrenade) and ((not S.stopAnimsOnFall) and true or onGround) and (not isCrawling)
2299
2300 crawlAlpha = math.min(math.max(crawlAlpha + (isCrawling and Increment or -Increment) * dt, 0), 90)
2301 idleAlpha = math.min(math.max(idleAlpha + (isIdling and Increment or -Increment) * dt, 0), 90)
2302 walkAlpha = math.min(math.max(walkAlpha + (isWalking and Increment or -Increment) * dt, 0), 90)
2303 runAlpha = math.min(math.max(runAlpha + (isRunning and Increment or -Increment) * dt, 0), 90)
2304
2305 local posHip = (
2306 Sine(idleAlpha) * (Anims.Idling["unAimed"](Anim.Ang)).Pos
2307 ) + (
2308 Sine(walkAlpha) * (Anims.Walking["unAimed"](Anim.Ang)).Pos
2309 ) + (
2310 Sine(runAlpha) * (Anims.Running(Anim.Ang)).Pos
2311 )
2312 local rotHip = (
2313 Sine(idleAlpha) * (Anims.Idling["unAimed"](Anim.Ang)).Rot
2314 ) + (
2315 Sine(walkAlpha) * (Anims.Walking["unAimed"](Anim.Ang)).Rot
2316 ) + (
2317 Sine(runAlpha) * (Anims.Running(Anim.Ang)).Rot
2318 )
2319 local posAim = (
2320 Sine(idleAlpha) * (Anims.Idling["Aimed"](Anim.Ang)).Pos
2321 ) + (
2322 Sine(walkAlpha) * (Anims.Walking["Aimed"](Anim.Ang)).Pos
2323 ) + (
2324 Sine(runAlpha) * (Anims.Running(Anim.Ang)).Pos
2325 )
2326 local rotAim = (
2327 Sine(idleAlpha) * (Anims.Idling["Aimed"](Anim.Ang)).Rot
2328 ) + (
2329 Sine(walkAlpha) * (Anims.Walking["Aimed"](Anim.Ang)).Rot
2330 ) + (
2331 Sine(runAlpha) * (Anims.Running(Anim.Ang)).Rot
2332 )
2333
2334 Anim.Pos = (1 - aimAlpha) * posHip + aimAlpha * posAim
2335 Anim.Rot = (1 - aimAlpha) * rotHip + aimAlpha * rotAim
2336
2337 Anim.Ang = Anim.Ang + RAD(105 * dt) * stanceSway
2338
2339 --Gun Momentum updating
2340 gunMomentum.t = V3(desiredXOffset, desiredYOffset, 0)
2341 local newGunMomentum = gunMomentum.p
2342 currentXOffset = newGunMomentum.X / S.momentumSettings.maxInput
2343 currentYOffset = newGunMomentum.Y / S.momentumSettings.maxInput
2344
2345 --Recoil spring updating
2346 gunRecoilSpring.t = recoilAnim.Rot
2347 camRecoilSpring.t = camOffsets.Recoil.Rot
2348
2349 --Cross spring updating
2350 if Aimed then
2351 crossSpring.t = V3(-2, 0, 0)
2352 else
2353 crossSpring.t = V3(crossOffset + (baseSpread + currentSpread) * 50, 0, 0)
2354 end
2355 local newS = crossSpring.p.X
2356 crossA.Position = UDim2.new(0.5, -1, 1, -newS / 2)
2357 crossB.Position = UDim2.new(0, newS / 2 - 15, 0.5, -1)
2358 crossC.Position = UDim2.new(0.5, -1, 0, newS / 2 - 15)
2359 crossD.Position = UDim2.new(1, -newS / 2, 0.5, -1)
2360
2361 --Orientation updating
2362 local finalCamOffset = getTotalCamOffset()
2363 headWeld.C1 = CFANG(-camAng.y - finalCamOffset.Y, 0, 0)
2364 if (not Humanoid.Sit) then
2365 HRP.CFrame = CF(HRP.Position) * CFANG(0, camAng.x + finalCamOffset.X, 0)
2366 end
2367
2368 --Walkspeed updating
2369 if Running then
2370 Humanoid.WalkSpeed = S.walkSpeeds.Sprinting
2371 else
2372 local SpeedRatio = S.walkSpeeds.Aimed / S.walkSpeeds.Base
2373 if Stance == 0 then
2374 Humanoid.WalkSpeed = (Aimed and S.walkSpeeds.Aimed or S.walkSpeeds.Base)
2375 elseif Stance == 1 then
2376 Humanoid.WalkSpeed = (Aimed and S.walkSpeeds.Crouched * SpeedRatio or S.walkSpeeds.Crouched)
2377 elseif Stance == 2 then
2378 Humanoid.WalkSpeed = (Aimed and S.walkSpeeds.Prone * SpeedRatio or S.walkSpeeds.Prone)
2379 end
2380 end
2381 end))
2382
2383 local crawlAng = 0
2384 while Selected do
2385 if isCrawling then
2386 breakReload = (Reloading and true or breakReload)
2387 if Aimed then unAimGun(true) end
2388 local tempCrawlAnim = Anims.Crawling(crawlAng, moveAng)
2389 spawn(function()
2390 local startCamRot = crawlCamRot
2391 local startLLegCF = LLegWeld.C1
2392 local startRLegCF = RLegWeld.C1
2393 local t0 = tick()
2394 while true do
2395 RS.Heartbeat:wait()
2396 local Alpha = math.min((tick() - t0) / 0.3, 1) * 90
2397 if (not isCrawling) then break end
2398 if (not Selected) then break end
2399 crawlCamRot = numLerp(startCamRot, tempCrawlAnim.Camera, Sine(Alpha))
2400 LLegWeld.C1 = startLLegCF:lerp(tempCrawlAnim.leftLeg, Linear(Alpha))
2401 RLegWeld.C1 = startRLegCF:lerp(tempCrawlAnim.rightLeg, Linear(Alpha))
2402 if Alpha == 90 then break end
2403 end
2404 end)
2405 tweenJoint(LWeld, nil, tempCrawlAnim.leftArm, Linear, 0.3)
2406 tweenJoint(RWeld, nil, tempCrawlAnim.rightArm, Linear, 0.3)
2407 tweenJoint(Grip, nil, tempCrawlAnim.Grip, Linear, 0.3)
2408 lowerSpread()
2409 local t0 = tick()
2410 while true do
2411 local dt = RS.Heartbeat:wait()
2412 if (not Selected) then break end
2413 if (not isCrawling) then break end
2414 if (tick() - t0) >= 0.3 then
2415 local crawlAnim = Anims.Crawling(crawlAng, moveAng)
2416 LWeld.C1 = crawlAnim.leftArm
2417 RWeld.C1 = crawlAnim.rightArm
2418 LLegWeld.C1 = crawlAnim.leftLeg
2419 RLegWeld.C1 = crawlAnim.rightLeg
2420 Grip.C1 = crawlAnim.Grip
2421 crawlCamRot = crawlAnim.Camera
2422 crawlAng = crawlAng + 0.5 * RAD(105 * dt) * (HRP.Velocity * V3(1, 0, 1)).magnitude / 3
2423 end
2424 end
2425 else
2426 crawlAng = 0
2427 if (not equipAnimPlaying) then
2428 spawn(function()
2429 local startCamRot = crawlCamRot
2430 local startLLegCF = LLegWeld.C1
2431 local startRLegCF = RLegWeld.C1
2432 local t0 = tick()
2433 while true do
2434 RS.RenderStepped:wait()
2435 local Alpha = math.min((tick() - t0) / 0.3, 1) * 90
2436 if isCrawling then break end
2437 if (not Selected) then break end
2438 crawlCamRot = numLerp(startCamRot, 0, Sine(Alpha))
2439 LLegWeld.C1 = startLLegCF:lerp(CF(), Linear(Alpha))
2440 RLegWeld.C1 = startRLegCF:lerp(CF(), Linear(Alpha))
2441 if Alpha == 90 then break end
2442 end
2443 end)
2444 if (not isRunning) then
2445 tweenJoint(LWeld, nil, S.unAimedC1.leftArm, Sine, 0.3)
2446 tweenJoint(RWeld, nil, S.unAimedC1.rightArm, Sine, 0.3)
2447 tweenJoint(Grip, nil, S.unAimedC1.Grip, Sine, 0.3)
2448 end
2449 end
2450 while true do
2451 if (not Selected) then break end
2452 if isCrawling then break end
2453 RS.RenderStepped:wait()
2454 end
2455 end
2456 wait()
2457 end
2458end
2459
2460function getAnimCF()
2461 return CF(aimHeadOffset, 0, 0) * CFANG(
2462 jumpAnim.Rot * COS(camAng.Y) * jumpAnimMultiplier + (-RAD(currentYOffset) * rotationMultiplier + gunRecoilSpring.p.X + Anim.Rot.X) * stanceSway,
2463 (-RAD(currentXOffset) * rotationMultiplier + gunRecoilSpring.p.Y + Anim.Rot.Y) * stanceSway,
2464 (RAD(currentXOffset) * rotationMultiplier + RAD(armTilt) * armTiltMultiplier + gunRecoilSpring.p.Z + Anim.Rot.Z) * stanceSway
2465 ) * CF(
2466 (Anim.Pos.X + recoilAnim.Pos.X) * stanceSway,
2467 jumpAnim.Pos * COS(camAng.Y) * jumpAnimMultiplier + (Anim.Pos.Y + recoilAnim.Pos.Y) * stanceSway,
2468 -jumpAnim.Pos * SIN(camAng.Y) * jumpAnimMultiplier + (Anim.Pos.Z + recoilAnim.Pos.Z) * stanceSway
2469 ), CFANG(-camAng.Y * crawlAlpha / 90, 0, 0) * CF(aimHeadOffset, -1, 0)
2470end
2471
2472--------------------[ FIRING FUNCTIONS ]----------------------------------------------
2473
2474function lowerSpread()
2475 if (not loweringSpread) then
2476 loweringSpread = true
2477 local Connection = nil
2478 Connection = RS.Heartbeat:connect(function(dt)
2479 if MB1Down and Firing then
2480 Connection:disconnect()
2481 end
2482 local newSpread = currentSpread - (S.spreadSettings.Decrease * dt)
2483 currentSpread = (newSpread < 0 and 0 or newSpread)
2484 if currentSpread == 0 then
2485 Connection:disconnect()
2486 end
2487 end)
2488 loweringSpread = false
2489 end
2490end
2491
2492local function autoFire()
2493 if (not canFire) then return end
2494 canFire = false
2495
2496 if (not Knifing) and (not ThrowingGrenade) then
2497 Firing = true
2498 while MB1Down and (not Reloading) and (not isCrawling) and (not Knifing) and (not ThrowingGrenade) do
2499 if Modes[((rawFireMode - 1) % numModes) + 1] ~= "AUTO" then break end
2500 if Humanoid.Health == 0 then break end
2501 if Ammo.Value > 0 then
2502 Ammo.Value = Ammo.Value - 1
2503 if Aimed and steadyKeyPressed and S.scopeSettings.unSteadyOnFire then
2504 steadyKeyPressed = false
2505 currentSteadyTime = 0
2506 end
2507 newMag = false
2508 fireGun()
2509 end
2510 if S.reloadSettings.magIsBullet then
2511 for _, Mag in pairs(Gun:GetChildren()) do
2512 if Mag.Name:sub(1, 3) == "Mag" then
2513 Mag.Transparency = 1
2514 end
2515 end
2516 end
2517 if Ammo.Value == 0 and S.reloadSettings.autoReload then
2518 wait(0.2)
2519 Reload()
2520 end
2521 wait(60 / S.roundsPerMin)
2522 end
2523 end
2524
2525 Firing = false
2526 canFire = true
2527end
2528
2529local function semiFire()
2530 if (not canFire) then return end
2531 canFire = false
2532
2533 if (not Knifing) and (not ThrowingGrenade) and (not isCrawling) and Humanoid.Health ~= 0 then
2534 Firing = true
2535 if Ammo.Value > 0 then
2536 Ammo.Value = Ammo.Value - 1
2537 if Aimed and steadyKeyPressed and S.scopeSettings.unSteadyOnFire then
2538 steadyKeyPressed = false
2539 currentSteadyTime = 0
2540 end
2541 newMag = false
2542 fireGun()
2543 end
2544 if S.reloadSettings.magIsBullet then
2545 for _, Mag in pairs(Gun:GetChildren()) do
2546 if Mag.Name:sub(1, 3) == "Mag" then
2547 Mag.Transparency = 1
2548 end
2549 end
2550 end
2551 if Ammo.Value == 0 and S.reloadSettings.autoReload then
2552 wait(0.2)
2553 Reload()
2554 end
2555 wait(60 / S.roundsPerMin)
2556 end
2557
2558 Firing = false
2559 canFire = true
2560end
2561
2562local function burstFire()
2563 if (not canFire) then return end
2564 canFire = false
2565
2566 local burstTime = 60 / S.roundsPerMin
2567 if (not Knifing) and (not ThrowingGrenade) and (not isCrawling) then
2568 Firing = true
2569 for i = 1, S.burstSettings.Amount do
2570 if Ammo.Value > 0 then
2571 Ammo.Value = Ammo.Value - 1
2572 if Humanoid.Health ~= 0 then
2573 if Aimed and steadyKeyPressed and S.scopeSettings.unSteadyOnFire then
2574 steadyKeyPressed = false
2575 currentSteadyTime = 0
2576 end
2577 newMag = false
2578 fireGun()
2579 end
2580 end
2581 if Ammo.Value == 0 and S.reloadSettings.autoReload then
2582 wait(0.2)
2583 Reload()
2584 break
2585 end
2586 wait(S.burstSettings.fireRateBurst and burstTime or S.burstSettings.Time / S.burstSettings.Amount)
2587 end
2588 end
2589 if S.reloadSettings.magIsBullet then
2590 for _, Mag in pairs(Gun:GetChildren()) do
2591 if Mag.Name:sub(1, 3) == "Mag" then
2592 Mag.Transparency = 1
2593 end
2594 end
2595 end
2596
2597 Firing = false
2598
2599 wait(S.burstSettings.fireRateBurst and burstTime or S.burstSettings.Wait)
2600
2601 canFire = true
2602end
2603
2604function fireGun()
2605 local fireSound = Handle:FindFirstChild("FireSound")
2606
2607 if fireSound then fireSound:Play() end
2608
2609 --[[local randSpread1 = RAD(RAND(0, 365))
2610 local randSpread2 = RAD(RAND(-(baseSpread + currentSpread), baseSpread + currentSpread, 0.01))
2611 local spreadDir = CFrame.fromAxisAngle(V3(0, 0, 1), randSpread1) * CFANG(randSpread2, 0, 0)
2612
2613 local originCF = ((Aimed and S.guiScope) and Head.CFrame or Handle.CFrame) * spreadDir
2614 local bulletDirection = CF(originCF.p, originCF.p + originCF.lookVector).lookVector
2615
2616 local newRay = Ray.new(Main.CFrame.p, bulletDirection * S.BulletRange)
2617 local H, P, N = workspace:FindPartOnRayWithIgnoreList(newRay, Ignore)
2618 createBulletImpact:FireServer(H, P, N, false, gunIgnore, S)]]
2619 --[[local Prob = math.random(1, math.floor((P - Head.CFrame.p).magnitude)) < 10
2620 if H and Prob then
2621 for i = 1, math.random(1, 3) do
2622 local pSpread1 = math.rad(math.random() * 365)
2623 local pSpread2 = math.rad(math.random(-30, 30))
2624 local pSpreadDir = CFrame.fromAxisAngle(Vector3.new(0, 0, 1), pSpread1) * CFrame.Angles(pSpread2, 0, 0)
2625 local particleDir = (CF(P, P + N) * pSpreadDir).lookVector
2626 spawn(function()
2627 local newParticle = Particle.new(
2628 {
2629 rayIgnore = Ignore;
2630 Color = Color3.new(1, 1, 191 / 255);
2631 Length = 1;
2632 Width = 0.2;
2633 p0 = P + particleDir * 0.5;
2634 v0 = particleDir * math.random(50, 100);
2635 a0 = Vector3.new(0, -196.2, 0);
2636 }
2637 )
2638 newParticle.obj.Parent = mainGUI
2639
2640 local t0 = tick()
2641 while true do
2642 if (tick() - t0) >= 0.2 then
2643 newParticle:delete()
2644 break
2645 end
2646 newParticle.t = (tick() - t0)
2647 RS.RenderStepped:wait()
2648 end
2649 end)
2650 end
2651 end]]
2652 ----------------------------------------------------------------------------------
2653 for _ = 1, (S.gunType.Shot and S.ShotAmount or 1) do
2654 local randSpread1 = RAD(RAND(0, 365))
2655 local randSpread2 = RAD(RAND(-(baseSpread + currentSpread), baseSpread + currentSpread, 0.01))
2656 local spreadDir = CFrame.fromAxisAngle(V3(0, 0, 1), randSpread1) * CFANG(randSpread2, 0, 0)
2657
2658 local originCF = ((Aimed and S.guiScope) and Head.CFrame or Handle.CFrame) * spreadDir
2659 local bulletDirection = CF(originCF.p, originCF.p + originCF.lookVector).lookVector
2660
2661 if S.bulletSettings.instantHit then
2662 local newRay = Ray.new(Main.CFrame.p, bulletDirection * S.bulletSettings.Range)
2663 local H, P, N = workspace:FindPartOnRayWithIgnoreList(newRay, Ignore)
2664 local finalP = P
2665 if H then
2666 if S.gunType.Explosive then
2667 if S.explosionSettings.soundId ~= "" then
2668 local soundPart = Instance.new("Part")
2669 soundPart.Transparency = 1
2670 soundPart.Anchored = true
2671 soundPart.CanCollide = false
2672 soundPart.Size = V3(1, 1, 1)
2673 soundPart.CFrame = CFrame.new(P)
2674 soundPart.Parent = gunIgnore
2675
2676 local Sound = Instance.new("Sound")
2677 Sound.Pitch = S.explosionSettings.Pitch
2678 Sound.SoundId = S.explosionSettings.soundId
2679 Sound.Volume = S.explosionSettings.Volume
2680 Sound.Parent = soundPart
2681 Sound:Play()
2682
2683 DS:AddItem(soundPart, Sound.TimeLength)
2684 end
2685 createBulletImpact:FireServer(H, P, N, bulletDirection, false, gunIgnore, S)
2686 createShockwave:FireServer(P, S.explosionSettings.Radius, gunIgnore, S)
2687 local E = Instance.new("Explosion")
2688 E.BlastPressure = S.explosionSettings.Pressure
2689 E.BlastRadius = S.explosionSettings.Radius
2690 E.DestroyJointRadiusPercent = (S.explosionSettings.rangeBasedDamage and 0 or 1)
2691 E.ExplosionType = S.explosionSettings.Type
2692 E.Position = P
2693 E.Hit:connect(function(Obj, Dist)
2694 if Obj.Name == "Torso" and (not Obj:IsDescendantOf(Char)) then
2695 if S.explosionSettings.rangeBasedDamage then
2696 local Dir = (Obj.Position - P).unit
2697 local expH, _ = workspace:FindPartOnRayWithIgnoreList(
2698 Ray.new(P - Dir * 0.1, Dir * 999),
2699 Ignore
2700 )
2701 local rayHitHuman = expH:IsDescendantOf(Obj.Parent)
2702 if (S.explosionSettings.rayCastExplosions and rayHitHuman) or (not S.explosionSettings.rayCastExplosions) then
2703 local hitHumanoid = findFirstClass(Obj.Parent, "Humanoid")
2704 if hitHumanoid and hitHumanoid.Health > 0 and isEnemy(hitHumanoid) then
2705 local distFactor = Dist / S.explosionSettings.Radius
2706 local distInvert = math.max(1 - distFactor,0)
2707 local newDamage = distInvert * getBaseDamage((P - Main.CFrame.p).magnitude)
2708
2709 local Tag = Instance.new("ObjectValue")
2710 Tag.Value = Player
2711 Tag.Name = "creator"
2712 Tag.Parent = hitHumanoid
2713 DS:AddItem(Tag, 0.3)
2714 hitHumanoid:TakeDamage(newDamage)
2715 markHit()
2716 end
2717 end
2718 else
2719 local hitHumanoid = findFirstClass(Obj.Parent, "Humanoid")
2720 if hitHumanoid and hitHumanoid.Health > 0 and isEnemy(hitHumanoid) then
2721 local Tag = Instance.new("ObjectValue")
2722 Tag.Value = Player
2723 Tag.Name = "creator"
2724 Tag.Parent = hitHumanoid
2725 DS:AddItem(Tag, 0.3)
2726 markHit()
2727 end
2728 end
2729 end
2730 end)
2731 E.Parent = game.Workspace
2732 else
2733 _, finalP = penetrateWall(H, P, bulletDirection, N, {Char, ignoreModel}, 0, (P - Main.CFrame.p).magnitude, nil)
2734 end
2735 end
2736 if S.bulletTrail and S.trailSettings.Transparency ~= 1 then
2737 createTrail:FireServer(Main.CFrame.p, finalP, gunIgnore, S)
2738 end
2739 else
2740 --[[local Bullet = CreateBullet(Direction)
2741 local LastPos = Main.CFrame.p
2742 local TotalDistTraveled = 0
2743 local HitHumanoid = nil
2744 spawn(function()
2745 while true do
2746 RS.RenderStepped:wait()
2747 if TotalDistTraveled >= S.BulletRange then
2748 Bullet:Destroy()
2749 break
2750 end
2751 local DistTraveled = (Bullet.Position - LastPos).magnitude
2752 local HitObj, HitPos = AdvRayCast(LastPos, (Bullet.Position - LastPos).unit, DistTraveled)
2753 if HitObj then
2754 if S.gunType.Explosive then
2755 if S.ExplosionSound ~= "" then
2756 local Sound = Instance.new("Sound")
2757 Sound.Pitch = S.ExplosionSoundPitch
2758 Sound.SoundId = S.ExplosionSound
2759 Sound.Volume = S.ExplosionSoundVolume
2760 Sound.Parent = Bullet
2761 Sound:Play()
2762 end
2763 print("BulletImpact called from Fire function")
2764 CreateBulletImpact(HitPos, HitObj)
2765 CreateShockwave(HitPos, S.ExplosionRadius)
2766 local E = Instance.new("Explosion")
2767 E.BlastPressure = S.ExplosionPressure
2768 E.BlastRadius = S.ExplosionRadius
2769 E.DestroyJointRadiusPercent = (S.RangeBasedDamage and 0 or 1)
2770 E.ExplosionType = S.ExplosionType
2771 E.Position = HitPos
2772 E.Hit:connect(function(HObj, HDist)
2773 if HObj.Name == "Torso" and (not HObj:IsDescendantOf(Char)) then
2774 if S.RangeBasedDamage then
2775 local Dir = (HObj.Position - HitPos).unit
2776 local H, P = AdvRayCast(HitPos - Dir, Dir, 999)
2777 local RayHitHuman = H:IsDescendantOf(HObj.Parent)
2778 if (S.RayCastExplosions and RayHitHuman) or (not S.RayCastExplosions) then
2779 local HitHumanoid = findFirstClass(HObj.Parent, "Humanoid")
2780 if HitHumanoid and HitHumanoid.Health > 0 and isEnemy(HitHumanoid) then
2781 local DistFactor = HDist / S.ExplosionRadius
2782 local DistInvert = math.max(1 - DistFactor,0)
2783 local NewDamage = DistInvert * S.Damage
2784
2785 local CreatorTag = Instance.new("ObjectValue")
2786 CreatorTag.Value = Player
2787 CreatorTag.Name = "creator"
2788 CreatorTag.Parent = HitHumanoid
2789 HitHumanoid:TakeDamage(NewDamage)
2790 markHit()
2791 end
2792 end
2793 else
2794 local HitHumanoid = findFirstClass(HObj.Parent, "Humanoid")
2795 if HitHumanoid and HitHumanoid.Health > 0 and isEnemy(HitHumanoid) then
2796 local CreatorTag = Instance.new("ObjectValue")
2797 CreatorTag.Value = Player
2798 CreatorTag.Name = "creator"
2799 CreatorTag.Parent = HitHumanoid
2800 markHit()
2801 end
2802 end
2803 end
2804 end)
2805 E.Parent = game.Workspace
2806 else
2807 HitHumanoid = Damage(HitObj, HitPos)
2808 end
2809 if S.Penetration > 0 and (not S.gunType.Explosive) then
2810 PenetrateWall(HitPos, (Bullet.Position - LastPos).unit, HitHumanoid, OriginPos, Bullet, 0)
2811 else
2812 Bullet:Destroy()
2813 end
2814 break
2815 else
2816 LastPos = Bullet.Position
2817 TotalDistTraveled = TotalDistTraveled + DistTraveled
2818 end
2819 end
2820 end)
2821
2822 if S.BulletTrail and S.TrailTransparency ~= 1 then
2823 spawn(function()
2824 local LastPos2 = nil
2825 while true do
2826 if LastPos2 then
2827 if (not Bullet:IsDescendantOf(game)) then break end
2828 Bullet.CFrame = CFrame.new(Bullet.CFrame.p, Bullet.CFrame.p + Bullet.Velocity)
2829 local Trail = Instance.new("Part")
2830 Trail.BrickColor = S.TrailColor
2831 Trail.Transparency = S.TrailTransparency
2832 Trail.Anchored = true
2833 Trail.CanCollide = false
2834 Trail.Size = V3(1, 1, 1)
2835 local Mesh = Instance.new("BlockMesh")
2836 Mesh.Offset = V3(0, 0, -(Bullet.Position - LastPos2).magnitude / 2)
2837 Mesh.Scale = V3(S.TrailThickness, S.TrailThickness, (Bullet.Position - LastPos2).magnitude)
2838 Mesh.Parent = Trail
2839 Trail.Parent = gunIgnore
2840 Trail.CFrame = CF(LastPos2, Bullet.Position)
2841 delay(S.TrailVisibleTime, function()
2842 if S.TrailDisappearTime > 0 then
2843 local X = 0
2844 while true do
2845 if X == 90 then break end
2846 if (not Selected) then break end
2847 local NewX = X + (1.5 / S.TrailDisappearTime)
2848 X = (NewX > 90 and 90 or NewX)
2849 local Alpha = X / 90
2850 Trail.Transparency = numLerp(S.TrailTransparency, 1, Alpha)
2851 RS.RenderStepped:wait()
2852 end
2853 Trail:Destroy()
2854 else
2855 Trail:Destroy()
2856 end
2857 end)
2858 LastPos2 = Bullet.Position
2859 else
2860 LastPos2 = Main.CFrame.p
2861 end
2862 RS.RenderStepped:wait()
2863 end
2864 end)
2865 end]]
2866 end
2867 end
2868
2869 ----------------------------------------------------------------------------------
2870
2871 currentSpread = currentSpread + S.spreadSettings.Increase
2872
2873 for _, Plugin in pairs(Plugins.Firing) do
2874 spawn(function()
2875 Plugin()
2876 end)
2877 end
2878
2879 local backRecoil = RAND(S.recoilSettings.Recoil.Back.Min, S.recoilSettings.Recoil.Back.Max, 0.01) --Get the kickback recoil
2880 local upRecoil = RAND(S.recoilSettings.Recoil.Up.Min, S.recoilSettings.Recoil.Up.Max, 0.01) --Get the up recoil
2881 local sideRecoilAlpha = 0
2882 if lastSideRecoil[1] < 0 and lastSideRecoil[2] < 0 then --This conditional basically makes sure the gun tilt isn't in the same direction for more than 2 shots
2883 sideRecoilAlpha = RAND(0, 1, 0.1)
2884 elseif lastSideRecoil[1] > 0 and lastSideRecoil[2] > 0 then
2885 sideRecoilAlpha = RAND(-1, 0, 0.1)
2886 else
2887 sideRecoilAlpha = RAND(-1, 1, 0.1)
2888 end
2889 local sideRecoil = numLerp(S.recoilSettings.Recoil.Side.Left, S.recoilSettings.Recoil.Side.Right, sideRecoilAlpha / 2 + 0.5) --Get the side recoil
2890 local tiltRecoil = numLerp(S.recoilSettings.Recoil.Tilt.Left, S.recoilSettings.Recoil.Tilt.Right, sideRecoilAlpha / 2 + 0.5) --Get the tilt recoil
2891 local recoilPos = V3(
2892 0,---sideRecoil,
2893 0,
2894 -backRecoil
2895 ) * (Aimed and S.recoilSettings.aimedMultiplier or 1)
2896 local recoilRot = V3(
2897 (Aimed and 0 or (-RAD(upRecoil * 10) * (firstShot and S.recoilSettings.firstShotMultiplier or 1))),
2898 RAD(sideRecoil * 10),
2899 RAD(tiltRecoil * 10)
2900 ) * (Aimed and S.recoilSettings.aimedMultiplier or 1)
2901 local camRecoilRot = V3(
2902 -RAD(sideRecoil * 10),
2903 RAD(upRecoil * 10) * (firstShot and S.recoilSettings.firstShotMultiplier or 1) * S.recoilSettings.camMultiplier,
2904 0
2905 ) * (Aimed and S.recoilSettings.aimedMultiplier or 1) * stanceSway
2906 tweenRecoil(recoilPos, recoilRot, Sine, 0.2)
2907 tweenCam("Recoil", camRecoilRot, Sine, 0.15 * (firstShot and S.recoilSettings.firstShotMultiplier or 1))
2908
2909 for _, v in pairs(Main:GetChildren()) do
2910 if v.Name:sub(1, 7) == "FlashFX" then
2911 v.Enabled = true
2912 end
2913 end
2914
2915 delay(1 / 20, function()
2916 tweenRecoil(V3(), V3(), Sine, 0.2)
2917 tweenCam("Recoil", V3(), Sine, 0.2)
2918 for _, v in pairs(Main:GetChildren()) do
2919 if v.Name:sub(1, 7) == "FlashFX" then
2920 v.Enabled = false
2921 end
2922 end
2923 end)
2924
2925 updateClipAmmo()
2926 firstShot = false
2927 shotCount = shotCount + 1
2928 lastSideRecoil[(shotCount % 2) + 1] = sideRecoilAlpha
2929end
2930
2931function markHit()
2932 spawn(function()
2933 if mainGUI:IsDescendantOf(game) then
2934 hitMarker.Visible = true
2935 local startMark = tick()
2936 hitMarker.lastMark.Value = startMark
2937
2938 wait(0.5)
2939
2940 if hitMarker.lastMark.Value <= startMark then
2941 hitMarker.Visible = false
2942 end
2943 end
2944 end)
2945end
2946
2947--------------------[ ADS FUNCTIONS ]-------------------------------------------------
2948
2949function aimGun()
2950 if Reloading or Knifing or ThrowingGrenade or isCrawling or (not S.canADS) then return end
2951
2952 mouseSensitivity = aimSensitivity
2953
2954 for _, Plugin in pairs(Plugins.Aimed) do
2955 spawn(function()
2956 Plugin()
2957 end)
2958 end
2959
2960 Aimed = true
2961 Aiming = true
2962 Running = false
2963 spreadZoom = "Aimed"
2964 baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion]
2965 if S.aimSettings.Anim then
2966 local currentFOV = Cam.FieldOfView
2967 local currentTrans = Scope.BackgroundTransparency
2968 tweenJoint(LWeld, armC0[1], S.aimedC1.leftArm, Sine, S.aimSettings.Speed)
2969 tweenJoint(RWeld, armC0[2], S.aimedC1.rightArm, Sine, S.aimSettings.Speed)
2970 tweenJoint(LWeld2, nil, CF(), Sine, S.aimSettings.Speed)
2971 tweenJoint(RWeld2, nil, CF(), Sine, S.aimSettings.Speed)
2972 tweenJoint(Grip, nil, aimedGripCF, Sine, S.aimSettings.Speed)
2973 tweenJoint(headWeld2, nil, CF(0, -0.5, 0) * CFANG(0, 0, S.aimSettings.headTilt) * CF(0, 0.5, 0), Sine, S.aimSettings.Speed)
2974 local t0 = tick()
2975 while true do
2976 RS.RenderStepped:wait()
2977 local Alpha = math.min((tick() - t0) / S.aimSettings.Speed, 1) * 90
2978 if (not Aimed) then break end
2979 if (not Selected) then break end
2980 aimAlpha = Sine(Alpha)
2981 aimHeadOffset = headOffset.X * aimAlpha
2982 jumpAnimMultiplier = numLerp(1, S.fallSettings.aimEffect, aimAlpha)
2983 translationDivisor = numLerp(7, 20, aimAlpha)
2984 rotationMultiplier = numLerp(S.momentumSettings.Amplitude.unAimed, S.momentumSettings.Amplitude.Aimed, aimAlpha)
2985 armTiltMultiplier = numLerp(1, 0.2, aimAlpha)
2986 Cam.FieldOfView = numLerp(currentFOV, S.aimSettings.FOV, aimAlpha)
2987 if S.guiScope then
2988 Scope.BackgroundTransparency = numLerp(currentTrans, 0, aimAlpha)
2989 end
2990 if Alpha == 90 then break end
2991 end
2992 else
2993 LWeld.C0, LWeld.C1 = armC0[1], S.aimedC1.leftArm
2994 RWeld.C0, RWeld.C1 = armC0[2], S.aimedC1.rightArm
2995 LWeld2.C1, RWeld2.C1 = CF(), CF()
2996 animWeld.C0 = CF(0, 1, 0)
2997 Grip.C1 = aimedGripCF
2998 headWeld2.C1 = CF(0, -0.5, 0) * CFANG(0, 0, S.aimSettings.headTilt) * CF(0, 0.5, 0)
2999 aimAlpha = 1
3000 aimHeadOffset = headOffset.X
3001 jumpAnimMultiplier = S.fallSettings.aimEffect
3002 translationDivisor = 20
3003 rotationMultiplier = S.momentumSettings.Amplitude.Aimed
3004 armTiltMultiplier = 0.2
3005 Cam.FieldOfView = S.aimSettings.FOV
3006 end
3007 Aiming = (not Aimed)
3008 if (not Aiming) and S.guiScope then
3009 spawn(function()
3010 scopeSteady.Visible = true
3011 Scope.BackgroundTransparency = 1
3012 scopeMain.Visible = true
3013
3014 if armTable then
3015 for _, Obj in pairs(armTable[1].Model:GetChildren()) do
3016 if Obj:IsA("BasePart") then
3017 Obj.LocalTransparencyModifier = 1
3018 end
3019 end
3020 for _, Obj in pairs(armTable[2].Model:GetChildren()) do
3021 if Obj:IsA("BasePart") then
3022 Obj.LocalTransparencyModifier = 1
3023 end
3024 end
3025 elseif armModel then
3026 for _, Obj in pairs(armModel:GetChildren()) do
3027 if Obj:IsA("BasePart") then
3028 Obj.LocalTransparencyModifier = 1
3029 end
3030 end
3031 end
3032 for _, Obj in pairs(playerFolder:GetChildren()) do
3033 if Obj:IsA("BasePart") then
3034 Obj.LocalTransparencyModifier = 1
3035 end
3036 end
3037 for _, Obj in pairs(Gun:GetChildren()) do
3038 if Obj:IsA("BasePart") then
3039 Obj.LocalTransparencyModifier = 1
3040 end
3041 end
3042 end)
3043 spawn(function()
3044 local camAng = 0
3045 local idleCam = function()
3046 return V3(
3047 RAD(SIN(camAng * S.scopeSettings.Frequency.Idling)) * stanceSway * camSway * S.scopeSettings.Amplitude.Idling,
3048 RAD(SIN(camAng * 5 / 2 * S.scopeSettings.Frequency.Idling)) * stanceSway * camSway * S.scopeSettings.Amplitude.Idling * 0.75,
3049 0
3050 )
3051 end
3052 local walkCam = function()
3053 return V3(
3054 RAD(SIN(camAng * S.scopeSettings.Frequency.Walking)) * camSway * stanceSway * S.scopeSettings.Amplitude.Walking,
3055 RAD(SIN(camAng * 5 / 2 * S.scopeSettings.Frequency.Walking)) * camSway * stanceSway * S.scopeSettings.Amplitude.Walking * 0.75,
3056 0
3057 )
3058 end
3059 while Aimed do
3060 local dt = RS.RenderStepped:wait()
3061 camOffsets.guiScope.Rot = (Sine(idleAlpha) * idleCam()) + (Sine(walkAlpha) * walkCam())
3062 camAng = camAng + RAD(105 * dt) * stanceSway * camSway
3063 end
3064 end)
3065 end
3066end
3067
3068function unAimGun(Exception)
3069 if (not S.canADS) then return end
3070
3071 mouseSensitivity = S.sensitivitySettings.Default
3072
3073 for _, Plugin in pairs(Plugins.UnAimed) do
3074 spawn(function()
3075 Plugin()
3076 end)
3077 end
3078
3079 if S.guiScope then
3080 spawn(function()
3081 if armTable then
3082 for _, Obj in pairs(armTable[1].Model:GetChildren()) do
3083 if Obj:IsA("BasePart") then
3084 Obj.LocalTransparencyModifier = 0
3085 end
3086 end
3087 for _, Obj in pairs(armTable[2].Model:GetChildren()) do
3088 if Obj:IsA("BasePart") then
3089 Obj.LocalTransparencyModifier = 0
3090 end
3091 end
3092 elseif armModel then
3093 for _, Obj in pairs(armModel:GetChildren()) do
3094 if Obj:IsA("BasePart") then
3095 Obj.LocalTransparencyModifier = 0
3096 end
3097 end
3098 end
3099 for _, Obj in pairs(playerFolder:GetChildren()) do
3100 if Obj:IsA("BasePart") then
3101 Obj.LocalTransparencyModifier = 0
3102 end
3103 end
3104 for _, Obj in pairs(Gun:GetChildren()) do
3105 if Obj:IsA("BasePart") then
3106 Obj.LocalTransparencyModifier = 0
3107 end
3108 end
3109 end)
3110 end
3111
3112 if (not Exception) then
3113 if (not Aimed) then return end
3114 if (Reloading and Exception) or Knifing and (not ThrowingGrenade) then return end
3115 spreadZoom = "unAimed"
3116 baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion]
3117 Aimed = false
3118 Aiming = true
3119 if S.aimSettings.Anim then
3120 local currentFOV = Cam.FieldOfView
3121 local currentTrans = (Scope.BackgroundTransparency == 1 and (S.guiScope and 0 or 1) or Scope.BackgroundTransparency)
3122 scopeMain.Visible = false
3123 scopeSteady.Visible = false
3124 tweenJoint(LWeld, armC0[1], S.unAimedC1.leftArm, Sine, S.aimSettings.Speed)
3125 tweenJoint(RWeld, armC0[2], S.unAimedC1.rightArm, Sine, S.aimSettings.Speed)
3126 tweenJoint(headWeld2, nil, CF(), Sine, S.aimSettings.Speed)
3127 tweenJoint(Grip, nil, S.unAimedC1.Grip, Sine, S.aimSettings.Speed)
3128 local t0 = tick()
3129 while true do
3130 RS.RenderStepped:wait()
3131 local Alpha = math.min((tick() - t0) / S.aimSettings.Speed, 1) * 90
3132 if Aimed then break end
3133 if (not Selected) then break end
3134 aimAlpha = 1 - Sine(Alpha)--1 - COS(RAD(X))
3135 aimHeadOffset = headOffset.X * aimAlpha
3136 jumpAnimMultiplier = numLerp(1, S.fallSettings.aimEffect, aimAlpha)
3137 translationDivisor = numLerp(7, 20, aimAlpha)
3138 rotationMultiplier = numLerp(S.momentumSettings.Amplitude.unAimed, S.momentumSettings.Amplitude.Aimed, aimAlpha)
3139 armTiltMultiplier = numLerp(1, 0.2, aimAlpha)
3140 Cam.FieldOfView = numLerp(80, currentFOV, aimAlpha)
3141 Scope.BackgroundTransparency = numLerp(1, currentTrans, aimAlpha)
3142 if Alpha == 90 then break end
3143 end
3144 else
3145 scopeMain.Visible = false
3146 scopeSteady.Visible = false
3147 LWeld.C0, LWeld.C1 = armC0[1], S.unAimedC1.leftArm
3148 RWeld.C0, RWeld.C1 = armC0[2], S.unAimedC1.rightArm
3149 headWeld2.C0 = CF()
3150 Grip.C1 = S.unAimedC1.Grip
3151 aimAlpha = 0
3152 aimHeadOffset = 0
3153 jumpAnimMultiplier = 1
3154 translationDivisor = 7
3155 rotationMultiplier = S.momentumSettings.Amplitude.unAimed
3156 armTiltMultiplier = 1
3157 Cam.FieldOfView = 80
3158 Scope.BackgroundTransparency = 1
3159 end
3160 Aiming = Aimed
3161 else
3162 spawn(function()
3163 Aimed = false
3164 Aiming = false
3165 spreadZoom = "unAimed"
3166 baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion]
3167 local currentFOV = Cam.FieldOfView
3168 local currentTrans = (Scope.BackgroundTransparency == 1 and (S.guiScope and 0 or 1) or Scope.BackgroundTransparency)
3169 scopeMain.Visible = false
3170 scopeSteady.Visible = false
3171 tweenJoint(headWeld2, nil, CF(), Sine, S.aimSettings.Speed)
3172 if S.aimSettings.Anim then
3173 local t0 = tick()
3174 while true do
3175 RS.RenderStepped:wait()
3176 local Alpha = math.min((tick() - t0) / S.aimSettings.Speed, 1) * 90
3177 if Aimed then break end
3178 if (not Selected) then break end
3179 aimAlpha = 1 - Sine(Alpha)--1 - COS(RAD(90 - Alpha))
3180 aimHeadOffset = headOffset.X * aimAlpha
3181 jumpAnimMultiplier = numLerp(1, S.fallSettings.aimEffect, aimAlpha)
3182 translationDivisor = numLerp(7, 20, aimAlpha)
3183 rotationMultiplier = numLerp(S.momentumSettings.Amplitude.unAimed, S.momentumSettings.Amplitude.Aimed, aimAlpha)
3184 armTiltMultiplier = numLerp(1, 0.2, aimAlpha)
3185 Cam.FieldOfView = numLerp(80, currentFOV, aimAlpha)
3186 Scope.BackgroundTransparency = numLerp(1, currentTrans, aimAlpha)
3187 if Alpha == 90 then break end
3188 end
3189 else
3190 scopeMain.Visible = false
3191 scopeSteady.Visible = false
3192 aimAlpha = 0
3193 aimHeadOffset = 0
3194 jumpAnimMultiplier = 1
3195 translationDivisor = 7
3196 rotationMultiplier = S.momentumSettings.Amplitude.unAimed
3197 armTiltMultiplier = 1
3198 Cam.FieldOfView = 80
3199 Scope.BackgroundTransparency = 1
3200 end
3201 end)
3202 end
3203end
3204
3205--------------------[ TEXTURE CREATION FUNCTIONS ]------------------------------------
3206
3207function createBullet(Direction)
3208 local Origin = Gun.Main.CFrame.p
3209 local bulletCF = CF(Origin, Origin + Direction)
3210 local Bullet = Instance.new("Part")
3211 Bullet.BrickColor = S.bulletSettings.Color
3212 Bullet.Material = Enum.Material.Neon
3213 Bullet.Name = "Bullet"
3214 Bullet.CanCollide = false
3215 Bullet.FormFactor = "Custom"
3216 Bullet.Size = S.bulletSettings.Size
3217 Bullet.BottomSurface = "Smooth"
3218 Bullet.TopSurface = "Smooth"
3219 if math.min(S.bulletSettings.Size.X, S.bulletSettings.Size.Y, S.bulletSettings.Size.Z) < 0.2 then
3220 local Mesh = Instance.new("BlockMesh")
3221 Mesh.Scale = S.bulletSettings.Size / Vector3.new(
3222 math.max(S.bulletSettings.Size.X, 0.2),
3223 math.max(S.bulletSettings.Size.Y, 0.2),
3224 math.max(S.bulletSettings.Size.Z, 0.2)
3225 )
3226 Mesh.Parent = Bullet
3227 end
3228 local BF = Instance.new("BodyForce")
3229 BF.force = V3(0, Bullet:GetMass() * (196.2 - S.bulletSettings.Acceleration), 0)
3230 BF.Parent = Bullet
3231 Bullet.Parent = gunIgnore
3232 Bullet.CFrame = bulletCF + Direction * S.bulletSettings.Size.Z / 2
3233 Bullet.Velocity = Direction * S.bulletSettings.Velocity
3234 return Bullet
3235end
3236
3237--------------------[ HIT HANDLING FUNCTIONS ]----------------------------------------
3238
3239function getBaseDamage(Dist)
3240 local startDmg = S.damageSettings.Start.Damage
3241 local startDist = S.damageSettings.Start.Dist
3242 local endDmg = S.damageSettings.End.Damage
3243 local endDist = S.damageSettings.End.Dist
3244 return (
3245 (
3246 Dist < startDist * S.bulletSettings.Range
3247 ) and startDmg or
3248 (
3249 Dist >= startDist * S.bulletSettings.Range and
3250 Dist < endDist * S.bulletSettings.Range
3251 ) and numLerp(startDmg, endDmg, Map(Dist / S.bulletSettings.Range, startDist, endDist, 0, 1)) or
3252 (
3253 Dist >= endDist * S.bulletSettings.Range
3254 ) and endDmg
3255 )
3256end
3257
3258function Damage(H, P, N, D, Dist, customIgnore)
3259 local hVal = S.damageSettings.Multipliers.Head
3260 local cVal = S.damageSettings.Multipliers.Chest
3261 local lVal = S.damageSettings.Multipliers.Limbs
3262 local baseDamage = getBaseDamage(Dist)
3263 if Humanoid.Health ~= 0 then
3264 local hitHumanoid = nil
3265 if H.Parent:IsA("Hat") then
3266 table.insert(customIgnore, H)
3267 local newRay = Ray.new(P - D * 0.1, D * (S.bulletSettings.Range - Dist + 0.1))
3268 local newH, newP, newN = workspace:FindPartOnRayWithIgnoreList(newRay, customIgnore)
3269 if newH then
3270 hitHumanoid = Damage(newH, newP, newN, D, Dist + (newP - P).magnitude, customIgnore)
3271 end
3272 else
3273 hitHumanoid = findFirstClass(H.Parent, "Humanoid")
3274 if hitHumanoid and hitHumanoid.Health > 0 and isEnemy(hitHumanoid) then
3275 local Tag = Instance.new("ObjectValue")
3276 Tag.Value = Player
3277 Tag.Name = "creator"
3278 Tag.Parent = hitHumanoid
3279 DS:AddItem(Tag, 0.3)
3280 local chosenDamage = 0
3281 if H.Name == "Head" then
3282 chosenDamage = baseDamage * RAND(hVal, hVal + 0.1, 0.01)
3283 elseif H.Name == "Torso" then
3284 chosenDamage = baseDamage * RAND(cVal, cVal + 0.1, 0.01)
3285 else
3286 chosenDamage = baseDamage * RAND(lVal, lVal + 0.1, 0.01)
3287 end
3288 hitHumanoid:TakeDamage(chosenDamage)
3289 markHit()
3290 end
3291 end
3292 return hitHumanoid
3293 end
3294end
3295
3296function isWallIgnored(Wall)
3297 return (
3298 Wall.Transparency >= S.penetrationSettings.transparencyThreshold or
3299 (S.penetrationSettings.ignoreNonCanCollide and (not Wall.CanCollide)) or
3300 isIgnored(Wall, S.penetrationSettings.ignoreCustom)
3301 )
3302end
3303
3304function penetrateWall(Wall, hitPos, Direction, Normal, Ignore, totalPDist, totalBDist, lastDamagedHumanoid)
3305 local wallIgnore = isWallIgnored(Wall)
3306 local hitHumanoid = (Wall.Parent:IsA("Hat") and findFirstClass(Wall.Parent.Parent, "Humanoid") or findFirstClass(Wall.Parent, "Humanoid"))
3307 local damagedHumanoid = nil
3308 if hitHumanoid and hitHumanoid ~= lastDamagedHumanoid then
3309 lastDamagedHumanoid = hitHumanoid
3310 damagedHumanoid = Damage(Wall, hitPos, Normal, Direction, totalBDist, {Char, ignoreModel})
3311 else
3312 lastDamagedHumanoid = nil
3313 end
3314 local ignoreObject = hitHumanoid and (Wall.Parent:IsA("Hat") and Wall.Parent.Parent or Wall.Parent) or Wall
3315 table.insert(Ignore, ignoreObject)
3316 local rayLength = S.bulletSettings.Range - totalBDist
3317 local testRay = Ray.new(hitPos, Direction * (S.bulletSettings.Range - totalBDist))
3318 local H1, P1, N1 = workspace:FindPartOnRayWithIgnoreList(testRay, Ignore)
3319 local newIgnore = removeElement(Ignore, ignoreObject)
3320 local wallRay = Ray.new(P1 + Direction * 0.1, -Direction * (rayLength + 1))
3321 local H2, P2, N2 = workspace:FindPartOnRayWithIgnoreList(wallRay, Ignore)
3322 local newPDist = totalPDist + (wallIgnore and 0 or (getNearestPoint(P1, P2, hitPos) - hitPos).magnitude)
3323 local newBDist = totalBDist + (P1 - hitPos).magnitude
3324 local outOfRange = Round(newPDist, 0.001) > S.penetrationSettings.Dist or Round(newBDist, 0.001) > S.bulletSettings.Range
3325 if (not wallIgnore) then
3326 createBulletImpact:FireServer(Wall, hitPos, Normal, Direction, hitHumanoid, gunIgnore, S)
3327 if (not hitHumanoid) then
3328 createShockwave:FireServer(hitPos, S.shockwaveSettings.Radius, gunIgnore, S)
3329 end
3330 end
3331 if hitHumanoid and hitHumanoid.Health > 0 and isEnemy(hitHumanoid) and hitHumanoid == damagedHumanoid then
3332 createBlood:FireServer(Wall, P2, Direction, gunIgnore, S)
3333 end
3334 if outOfRange or (not H1) then
3335 if (not outOfRange) and (not wallIgnore) then
3336 createBulletImpact:FireServer(Wall, P2, N2, Direction, hitHumanoid, gunIgnore, S)
3337 if (not hitHumanoid) then
3338 createShockwave:FireServer(P2, S.shockwaveSettings.Radius, gunIgnore, S)
3339 end
3340 end
3341 return Wall, hitPos
3342 else
3343 if Wall == H2 and (not wallIgnore) then
3344 createBulletImpact:FireServer(Wall, P2, N2, Direction, hitHumanoid, gunIgnore, S)
3345 if (not hitHumanoid) then
3346 createShockwave:FireServer(P2, S.shockwaveSettings.Radius, gunIgnore, S)
3347 end
3348 end
3349 return penetrateWall(H1, P1, Direction, N1, Ignore, newPDist, newBDist, lastDamagedHumanoid)
3350 end
3351end
3352
3353function PenetrateWall(HitPos, Direction, HitHumanoid, OriginPos, Bullet, CurrentPDist)
3354 local HitDist = (HitPos - OriginPos).magnitude
3355 local Wall, WallHitPos = nil, nil
3356 local Hum, HumHitPos = nil, nil
3357 local CustomIgnore = {unpack(Ignore)}
3358 for i = 1, 10 do
3359 local WallRay = Ray.new(HitPos - (Direction * 0.1), Direction * S.Penetration)
3360 local H, P = game.Workspace:FindPartOnRayWithIgnoreList(WallRay, CustomIgnore)
3361 if H then
3362 local HitHumanoid = nil
3363 if H.Parent.ClassName == "Hat" then
3364 HitHumanoid = findFirstClass(H.Parent.Parent, "Humanoid")
3365 else
3366 HitHumanoid = findFirstClass(H.Parent, "Humanoid")
3367 end
3368 if HitHumanoid and i ~= 1 then
3369 Hum, HumHitPos = H, P
3370 break
3371 else
3372 Wall, WallHitPos = H, P
3373 table.insert(CustomIgnore, H)
3374 end
3375 else
3376 break
3377 end
3378 end
3379 if Wall then
3380 if S.InstantHit then
3381 if Hum then
3382 Damage(Hum.Parent:FindFirstChild("Head"), HumHitPos)
3383 return HumHitPos
3384 else
3385 local HitObj2, HitPos2 = nil, nil
3386 if HitHumanoid then
3387 HitObj2, HitPos2 = AdvRayCast(WallHitPos, Direction, S.BulletRange - HitDist, {Wall, HitHumanoid.Parent, unpack(Ignore)})
3388 else
3389 HitObj2, HitPos2 = AdvRayCast(WallHitPos, Direction, S.BulletRange - HitDist, {Wall, unpack(Ignore)})
3390 end
3391 Damage(HitObj2, HitPos2)
3392
3393 local NewPDist = CurrentPDist + (WallHitPos - HitPos).magnitude
3394 local NewHitPos2 = HitPos2
3395 if NewPDist < S.Penetration and HitObj2 then
3396 NewHitPos2 = PenetrateWall(HitPos2, Direction, HitHumanoid, OriginPos, Bullet, CurrentPDist + NewPDist)
3397 end
3398 return NewHitPos2
3399 end
3400 else
3401 local LastPos = WallHitPos
3402 local TotalDistTraveled = 0
3403 spawn(function()
3404 if Hum then
3405 Damage(Hum.Parent:FindFirstChild("Head"), HumHitPos)
3406 return HumHitPos
3407 else
3408 while true do
3409 RS.RenderStepped:wait()
3410 if TotalDistTraveled >= S.BulletRange - HitDist then
3411 Bullet:Destroy()
3412 break
3413 end
3414 local DistTraveled = (Bullet.Position - LastPos).magnitude
3415 local NewDirection = (Bullet.Position - LastPos).unit
3416 local TempHitObj, TempHitPos = nil, nil
3417 if HitHumanoid then
3418 TempHitObj, TempHitPos = AdvRayCast(LastPos, NewDirection, DistTraveled, {Wall, HitHumanoid.Parent, unpack(Ignore)})
3419 else
3420 TempHitObj, TempHitPos = AdvRayCast(LastPos, NewDirection, DistTraveled, {Wall, unpack(Ignore)})
3421 end
3422 if TempHitObj then
3423 Damage(TempHitObj, TempHitPos)
3424
3425 local NewPDist = CurrentPDist + (WallHitPos - HitPos).magnitude
3426 local NewTempPos = TempHitPos
3427 if NewPDist < S.Penetration and TempHitObj then
3428 NewTempPos = PenetrateWall(TempHitPos, Direction, HitHumanoid, OriginPos, Bullet, CurrentPDist + NewPDist)
3429 else
3430 Bullet:Destroy()
3431 end
3432 return NewTempPos
3433 else
3434 LastPos = Bullet.Position
3435 TotalDistTraveled = TotalDistTraveled + DistTraveled
3436 end
3437 end
3438 end
3439 end)
3440 end
3441 else
3442 if Bullet then Bullet:Destroy() end
3443 return HitPos
3444 end
3445end
3446
3447function isEnemy(Human)
3448 local Plyr = game.Players:GetPlayerFromCharacter(Human.Parent)
3449 if (not Plyr) then return S.CanDamageNPCs end
3450 return S.AllowFriendlyFire or (Plyr.TeamColor ~= Player.TeamColor or Plyr.Neutral)
3451end
3452
3453--------------------[ RELOAD FUNCTIONS ]----------------------------------------------
3454
3455function animateReload()
3456 tweenJoint(LWeld2, CF(), CF(), Sine, 0.15)
3457 tweenJoint(RWeld2, CF(), CF(), Sine, 0.15)
3458 local magParts = {}
3459 local magTable = {}
3460
3461 for _, Obj in pairs(Gun:GetChildren()) do
3462 if string.sub(Obj.Name, 1, 3) == "Mag" and Obj:IsA("BasePart") then
3463 INSERT(magParts, Obj)
3464 end
3465 end
3466
3467 local animVars = {
3468 --FUNCTIONS--
3469 tweenJoint = tweenJoint;
3470
3471 makeMagInvisible = function()
3472 for _, v in pairs(magParts) do
3473 v.Transparency = 1
3474 end
3475 magVisible = false
3476 end;
3477
3478 makeMagVisible = function()
3479 for _, v in pairs(magParts) do
3480 v.Transparency = v:WaitForChild("magTrans").Value
3481 end
3482 magVisible = true
3483 end;
3484
3485 isMagVisible = function()
3486 return magVisible
3487 end;
3488
3489 isMagEmpty = function()
3490 return ammoInClip == 0
3491 end;
3492
3493 setNewMag = function()
3494 newMag = true
3495 end;
3496
3497 isNewMag = function()
3498 return newMag
3499 end;
3500
3501 createMag = function(Key)
3502 local magModel = Instance.new("Model")
3503 local magClones = {}
3504 for i, v in pairs(magParts) do
3505 local vClone = v:Clone()
3506 vClone.Transparency = v:WaitForChild("magTrans").Value
3507 vClone.CanCollide = false
3508 vClone.Parent = magModel
3509 INSERT(magClones, {Original = v, magClone = vClone})
3510 if i ~= 1 then
3511 local W = Instance.new("Weld")
3512 W.Part0 = magClones[1].magClone
3513 W.Part1 = vClone
3514 W.C0 = magClones[1].magClone.CFrame:toObjectSpace(vClone.CFrame)
3515 W.Parent = magClones[1].magClone
3516 end
3517 end
3518 magTable[Key] = {magModel, magClones}
3519 return magModel, magClones
3520 end;
3521
3522 getMag = function(Key)
3523 if magTable[Key] then
3524 return magTable[Key][1], magTable[Key][2]
3525 else
3526 return nil, nil
3527 end
3528 end;
3529
3530 attachGripToHead = function()
3531 local handleCF = RArm.CFrame * Grip.C0
3532 Grip.C0 = Head.CFrame:toObjectSpace(handleCF)
3533 Grip.Part0 = Head
3534 end;
3535
3536 attachGripToArm = function()
3537 local handleCF = Head.CFrame * Grip.C0
3538 Grip.C0 = RArm.CFrame:toObjectSpace(handleCF)
3539 Grip.Part0 = RArm
3540 end;
3541
3542 Sine = Sine;
3543
3544 Linear = Linear;
3545
3546 --VARIABLES--
3547 Handle = Handle;
3548 LArm = LArm;
3549 RArm = RArm;
3550 LWeld = LWeld;
3551 RWeld = RWeld;
3552 LC0 = armC0[1];
3553 RC0 = armC0[2];
3554 Grip = Grip;
3555 gunIgnore = gunIgnore;
3556 Cam = Cam;
3557 CF = CF;
3558 CFANG = CFANG;
3559 V3 = V3;
3560 RAD = RAD;
3561 reloadTimeLoaded = S.reloadSettings.Times.Loaded;
3562 reloadTimeEmpty = S.reloadSettings.Times.Empty
3563 }
3564
3565 local sequenceTable = Anims.Reload(animVars)
3566 --local T = tick()
3567 for _, reloadFunction in pairs(sequenceTable) do
3568 if breakReload then
3569 break
3570 end
3571 reloadFunction()
3572
3573 if (not magVisible) then
3574 Ammo.Value = 0
3575 end
3576 updateClipAmmo()
3577 end
3578 --print(tick() - T) --I divide the reloadTime by this number to get the animation speed
3579
3580 if (not isCrawling) then
3581 if Running and (not S.canFireWhileRunning) then
3582 tweenJoint(LWeld, armC0[1], S.runningC1.leftArm, Sine, 0.4)
3583 tweenJoint(RWeld, armC0[2], S.runningC1.rightArm, Sine, 0.4)
3584 tweenJoint(Grip, nil, S.runningC1.Grip, Sine, 0.4)
3585 else
3586 tweenJoint(LWeld, armC0[1], S.unAimedC1.leftArm, Sine, 0.4)
3587 tweenJoint(RWeld, armC0[2], S.unAimedC1.rightArm, Sine, 0.4)
3588 tweenJoint(Grip, nil, S.unAimedC1.Grip, Sine, 0.4)
3589 end
3590 end
3591
3592 for _, v in pairs(magTable) do --In case the reload animations was stopped mid way and there were still fake mags that weren't deleted
3593 v[1]:Destroy()
3594 end
3595end
3596
3597function Reload()
3598 if Ammo.Value < (ClipSize.Value + 1) and (not Reloading) and StoredAmmo.Value > 0 then
3599 Firing = false
3600 ammoInClip = (ammoInClip == 0 and Ammo.Value or ammoInClip)
3601 Reloading = true
3602 lowerSpread()
3603 if Aimed then unAimGun(S.reloadSettings.Anim) end
3604 crossHair.Reload.Visible = true
3605 if Handle:FindFirstChild("ReloadSound") then Handle.ReloadSound:Play() end
3606 if S.reloadSettings.Anim then
3607 wait()
3608 animateReload()
3609 else
3610 local startReload = tick()
3611 local initialReloadTime = Ammo.Value == 0 and S.reloadSettings.Times.Empty or S.reloadSettings.Times.Loaded
3612 while true do
3613 if breakReload then break end
3614 if (tick() - startReload) >= initialReloadTime then break end
3615 RS.RenderStepped:wait()
3616 end
3617 end
3618 if (not breakReload) then
3619 newMag = false
3620 if StoredAmmo.Value >= ClipSize.Value then
3621 if ammoInClip > 0 then
3622 StoredAmmo.Value = StoredAmmo.Value - ((ClipSize.Value + 1) - ammoInClip)
3623 Ammo.Value = ClipSize.Value + 1
3624 else
3625 StoredAmmo.Value = StoredAmmo.Value - ClipSize.Value
3626 Ammo.Value = ClipSize.Value
3627 end
3628 elseif StoredAmmo.Value < ClipSize.Value and StoredAmmo.Value > 0 then
3629 Ammo.Value = StoredAmmo.Value
3630 StoredAmmo.Value = 0
3631 end
3632 end
3633 Reloading = false
3634 if Selected then
3635 ammoInClip = (breakReload and ammoInClip or 0)
3636 crossHair.Reload.Visible = false
3637 end
3638 breakReload = false
3639 end
3640
3641 updateClipAmmo()
3642 updateStoredAmmo()
3643end
3644
3645--------------------[ EXTERNAL DATA LOCATING FUNCTIONS ]-----------------------------
3646
3647function removeElement(Table, Element) --removes the first instance of Element from Table
3648 for i, v in pairs(Table) do
3649 if v == Element then
3650 table.remove(Table, i)
3651 break
3652 end
3653 end
3654 return Table
3655end
3656
3657function findFirstClass(Object, Class)
3658 local foundObject = nil
3659 for _, Obj in pairs(Object:GetChildren()) do
3660 if Obj.ClassName == Class then
3661 foundObject = Obj
3662 break
3663 end
3664 end
3665 return foundObject
3666end
3667
3668function isIgnored(Obj, Table)
3669 for _,v in pairs(Table) do
3670 if Obj == v or Obj:IsDescendantOf(v) then
3671 return true
3672 end
3673 end
3674 return false
3675end
3676
3677function GetHitSurfaceCFrame(HitPos,Obj)
3678 local SurfaceCF = {
3679 {"Back",Obj.CFrame * CF(0,0,Obj.Size.z)};
3680 {"Bottom",Obj.CFrame * CF(0,-Obj.Size.y,0)};
3681 {"Front",Obj.CFrame * CF(0,0,-Obj.Size.z)};
3682 {"Left",Obj.CFrame * CF(-Obj.Size.x,0,0)};
3683 {"Right",Obj.CFrame * CF(Obj.Size.x,0,0)};
3684 {"Top",Obj.CFrame * CF(0,Obj.Size.y,0)}
3685 }
3686 local ClosestDist = HUGE
3687 local ClosestSurface = nil
3688 for _,v in pairs(SurfaceCF) do
3689 local SurfaceDist = (HitPos - v[2].p).magnitude
3690 if SurfaceDist < ClosestDist then
3691 ClosestDist = SurfaceDist
3692 ClosestSurface = v
3693 end
3694 end
3695 return ClosestSurface[2]
3696end
3697
3698function AdvRayCast(Origin, Direction, Dist, CustomIgnore)
3699 local NewIgnore = (CustomIgnore and CustomIgnore or Ignore)
3700 local NewRay = Ray.new(Origin, Direction * (Dist > 999 and 999 or Dist))
3701 local HitObj, HitPos = game.Workspace:FindPartOnRayWithIgnoreList(NewRay, NewIgnore)
3702 local LastPos = HitPos
3703 local FinalHitObj, FinalHitPos = nil, nil
3704 local RepTimes = math.floor(Dist / 999)
3705 if (not HitObj) and (Dist > 999) then
3706 for i = 0, RepTimes do
3707 local NewDist = (i == RepTimes and (Dist - (LastPos - Origin).magnitude) or 999)
3708 local Ray2 = Ray.new(LastPos, Direction * NewDist)
3709 local HitObj2, HitPos2 = game.Workspace:FindPartOnRayWithIgnoreList(Ray2, NewIgnore)
3710 if i ~= RepTimes then
3711 if HitObj2 then
3712 FinalHitObj, FinalHitPos = HitObj2, HitPos2
3713 break
3714 end
3715 elseif i == RepTimes then
3716 FinalHitObj, FinalHitPos = HitObj2, HitPos2
3717 end
3718 LastPos = HitPos2
3719 end
3720 return FinalHitObj, FinalHitPos
3721 elseif HitObj or (Dist <= 999) then
3722 return HitObj, HitPos
3723 end
3724end
3725
3726--------------------[ JUMPING ANIMATION ]---------------------------------------------
3727
3728function onFall(initialVelocity)
3729 spawn(function()
3730 local velocityAlpha = math.max(math.min(initialVelocity / Humanoid.JumpPower, 1), 0)
3731 local startJumpPos = jumpAnim.Pos
3732 local startJumpRot = jumpAnim.Rot
3733 local endJumpPos = 0.04 * S.fallSettings.fallMultiplier * velocityAlpha
3734 local endJumpRot = RAD(4) * S.fallSettings.fallMultiplier * velocityAlpha
3735 local t0 = tick()
3736 while true do
3737 RS.Heartbeat:wait()
3738 local Alpha = math.min((tick() - t0) / 0.15, 1) * 90
3739 if onGround then break end
3740 jumpAnim.Pos = numLerp(startJumpPos, endJumpPos, Sine(Alpha))
3741 jumpAnim.Rot = numLerp(startJumpRot, endJumpRot, Sine(Alpha))
3742 if Alpha == 90 then break end
3743 end
3744 startJumpPos = endJumpPos
3745 startJumpRot = endJumpRot
3746 endJumpPos = -0.08 * S.fallSettings.fallMultiplier
3747 endJumpRot = -RAD(8) * S.fallSettings.fallMultiplier
3748 local X = 1
3749 while true do
3750 local dt = RS.Heartbeat:wait()
3751 X = X + (dt * 60) / X
3752 local Alpha = (X - 1) / 15
3753 if onGround then break end
3754 jumpAnim.Pos = numLerp(startJumpPos, endJumpPos, Alpha)
3755 jumpAnim.Rot = numLerp(startJumpRot, endJumpRot, Alpha)
3756 end
3757 end)
3758end
3759
3760function onLand(fallDist)
3761 spawn(function()
3762 local animAlpha = math.min(fallDist, S.fallSettings.maxDist) * (2 / 3)
3763 local startJumpPos = jumpAnim.Pos
3764 local startJumpRot = jumpAnim.Rot
3765 local endJumpPos = animAlpha / 100 * S.fallSettings.landMultiplier * (runReady and 1 or 2)
3766 local endJumpRot = RAD(animAlpha) * S.fallSettings.landMultiplier * (runReady and 1 or 2)
3767 local t0 = tick()
3768 while true do
3769 RS.Heartbeat:wait()
3770 local Alpha = math.min((tick() - t0) / 0.2, 1)
3771 if (not onGround) then break end
3772 jumpAnim.Pos = numLerp(startJumpPos, endJumpPos, Alpha)
3773 jumpAnim.Rot = numLerp(startJumpRot, endJumpRot, Alpha)
3774 if Alpha == 1 then break end
3775 end
3776 t0 = tick()
3777 while true do
3778 RS.Heartbeat:wait()
3779 local Alpha = math.min((tick() - t0) / 0.3, 1) * 90
3780 if (not onGround) then break end
3781 jumpAnim.Pos = numLerp(endJumpPos, 0, Sine(Alpha))
3782 jumpAnim.Rot = numLerp(endJumpRot, 0, Sine(Alpha))
3783 if Alpha == 90 then break end
3784 end
3785 end)
3786end
3787
3788function onHumanoidStateChanged(oldState, newState)
3789 if newState == Enum.HumanoidStateType.Freefall then
3790 onGround = false
3791 if S.fallAnimation then
3792 onFall(HRP.Velocity.Y)
3793 while HRP.Velocity.Y > 0 do RS.RenderStepped:wait() end
3794 startFallHeight = HRP.Position.Y
3795 end
3796 elseif oldState == Enum.HumanoidStateType.Freefall then
3797 onGround = true
3798 if S.fallAnimation then
3799 local fallDist = startFallHeight - HRP.Position.Y
3800 onLand(fallDist)
3801 end
3802 end
3803end
3804
3805--------------------[ KNIFING ANIMATION ]---------------------------------------------
3806
3807function CreateKnife()
3808 local Knife = Instance.new("Model")
3809 Knife.Name = "Knife"
3810
3811 local Center = Instance.new("Part")
3812 Center.BrickColor = S.LethalGrenadeColor
3813 Center.Name = "Center"
3814 Center.CanCollide = false
3815 Center.FormFactor = Enum.FormFactor.Custom
3816 Center.Size = V3(1, 1, 3)
3817 Center.Parent = Knife
3818
3819 local Mesh = Instance.new("SpecialMesh")
3820 Mesh.MeshId = "http://www.roblox.com/asset/?id=12221720"
3821 Mesh.MeshType = Enum.MeshType.FileMesh
3822 Mesh.Scale = V3(0.5, 0.5, 0.5)
3823 Mesh.Parent = Center
3824
3825 return Knife
3826end
3827
3828function Knife()
3829 if KnifeReady and (not Knifing) and (not ThrowingGrenade) then
3830 if Aimed then unAimGun(true) end
3831 breakReload = true
3832 Knifing = true
3833 KnifeReady = false
3834 if S.KnifeAnim == 1 then
3835 KnifeAnim1()
3836 else
3837 KnifeAnim2()
3838 end
3839 breakReload = false
3840 Knifing = false
3841 delay(S.KnifeCooldown, function()
3842 KnifeReady = true
3843 end)
3844 end
3845end
3846
3847function KnifeAnim1()
3848 local Connection = nil
3849 local Blade = Instance.new("Part")
3850 Blade.BrickColor = BrickColor.new("Really black")
3851 Blade.Name = "Blade"
3852 Blade.CanCollide = false
3853 Blade.FormFactor = Enum.FormFactor.Custom
3854 Blade.Size = V3(0.5, 2.5, 1)
3855 local Mesh = Instance.new("SpecialMesh")
3856 Mesh.MeshId = S.KnifeMeshId
3857 Mesh.MeshType = Enum.MeshType.FileMesh
3858 Mesh.Scale = V3(0.7, 0.7, 0.7)
3859 Mesh.TextureId = S.KnifeTextureId
3860 Mesh.Parent = Blade
3861 Blade.Parent = gunIgnore
3862 local BladeWeld = Instance.new("Weld")
3863 BladeWeld.Part0 = Blade
3864 BladeWeld.Part1 = fakeLArm
3865 BladeWeld.C0 = CFANG(RAD(-90), 0, RAD(180))
3866 BladeWeld.C1 = CF(0, -1, 0.75)
3867 BladeWeld.Parent = Blade
3868 Connection = Blade.Touched:connect(function(Obj)
3869 if Obj then
3870 local HitHumanoid = findFirstClass(Obj.Parent, "Humanoid")
3871 if HitHumanoid and isEnemy(HitHumanoid) then
3872 local CreatorTag = Instance.new("ObjectValue")
3873 CreatorTag.Name = "creator"
3874 CreatorTag.Value = Player
3875 CreatorTag.Parent = HitHumanoid
3876 HitHumanoid:TakeDamage(HitHumanoid.MaxHealth)
3877 markHit()
3878 end
3879 end
3880 end)
3881 tweenJoint(LWeld2, CF(), CFANG(0, RAD(90), 0), Linear, 0.05)
3882 tweenJoint(LWeld, armC0[1], CF(-0.1, 0.2, -0.1) * CFANG(0, 0, RAD(-20)), Linear, 0.05)
3883 tweenJoint(RWeld, armC0[2], CF(0, 0.5, 0) * CFANG(RAD(80), 0, 0), Linear, 0.1)
3884 tweenJoint(Grip, Grip.C0, CF(), Linear, 0.1)
3885 spawn(function()
3886 local Force = HRP.CFrame.lookVector * 8e4
3887 local BF = Instance.new("BodyForce")
3888 BF.force = Force
3889 BF.Parent = HRP
3890 delay(0.03, function()
3891 BF.force = -Force / 2
3892 wait(0.03)
3893 BF:Destroy()
3894 end)
3895 end)
3896 wait(0.05)
3897 RotCam(RAD(6), 0, true, 0.1)
3898 delay(0.1, function()
3899 RotCam(RAD(-2), 0, true, 0.05)
3900 end)
3901 tweenJoint(LWeld, armC0[1], CF(0.7, 1.7, 0) * CFANG(RAD(-10), 0, RAD(-90)), Linear, 0.06)
3902 wait(0.1)
3903 Connection:disconnect()
3904 wait(0.2)
3905 tweenJoint(LWeld2, CF(), CF(), Linear, 0.15)
3906 tweenJoint(LWeld, armC0[1], S.unAimedC1.leftArm, Linear, 0.15)
3907 tweenJoint(RWeld, armC0[2], S.unAimedC1.rightArm, Linear, 0.15)
3908 Blade:Destroy()
3909end
3910
3911function KnifeAnim2()
3912 local Connection = nil
3913 local Blade = Instance.new("Part")
3914 Blade.BrickColor = BrickColor.new("Really black")
3915 Blade.Name = "Blade"
3916 Blade.CanCollide = false
3917 Blade.FormFactor = Enum.FormFactor.Custom
3918 Blade.Size = V3(0.5, 2.5, 1)
3919 local Mesh = Instance.new("SpecialMesh")
3920 Mesh.MeshId = S.KnifeMeshId
3921 Mesh.MeshType = Enum.MeshType.FileMesh
3922 Mesh.Scale = V3(0.7, 0.7, 0.7)
3923 Mesh.TextureId = S.KnifeTextureId
3924 Mesh.Parent = Blade
3925 Blade.Parent = gunIgnore
3926 local BladeWeld = Instance.new("Weld")
3927 BladeWeld.Part0 = Blade
3928 BladeWeld.Part1 = fakeLArm
3929 BladeWeld.C0 = CFANG(RAD(-90), 0, RAD(180))
3930 BladeWeld.C1 = CF(0, -1, 0.75)
3931 BladeWeld.Parent = Blade
3932 Connection = Blade.Touched:connect(function(Obj)
3933 if Obj then
3934 local HitHumanoid = findFirstClass(Obj.Parent, "Humanoid")
3935 if HitHumanoid and isEnemy(HitHumanoid) then
3936 local CreatorTag = Instance.new("ObjectValue")
3937 CreatorTag.Name = "creator"
3938 CreatorTag.Value = Player
3939 CreatorTag.Parent = HitHumanoid
3940 HitHumanoid:TakeDamage(HitHumanoid.MaxHealth)
3941 markHit()
3942 end
3943 end
3944 end)
3945 tweenJoint(LWeld2, CF(), CFANG(0, RAD(90), 0), Linear, 0.05)
3946 tweenJoint(LWeld, armC0[1], CF(0.4, 1.5, -0.2) * CFANG(0, 0, RAD(-80)), Linear, 0.05)
3947 tweenJoint(RWeld, armC0[2], CFANG(RAD(-30), 0, 0), Linear, 0.1)
3948 tweenJoint(Grip, Grip.C0, CF(), Linear, 0.1)
3949 spawn(function()
3950 local Force = HRP.CFrame.lookVector * 8e4
3951 local BF = Instance.new("BodyForce")
3952 BF.force = Force
3953 BF.Parent = HRP
3954 delay(0.03, function()
3955 BF.force = -Force / 2
3956 wait(0.03)
3957 BF:Destroy()
3958 end)
3959 end)
3960 wait(0.05)
3961 RotCam(RAD(6), 0, true, 0.1)
3962 delay(0.1, function()
3963 RotCam(RAD(-2), 0, true, 0.05)
3964 end)
3965 tweenJoint(LWeld, armC0[1], CF(1, 1.5, 0.2) * CFANG(0, 0, RAD(-80)), Linear, 0.06)
3966 wait(0.1)
3967 Connection:disconnect()
3968 wait(0.1)
3969 tweenJoint(LWeld2, CF(), CF(), Linear, 0.15)
3970 tweenJoint(LWeld, armC0[1], S.unAimedC1.leftArm, Linear, 0.15)
3971 tweenJoint(RWeld, armC0[2], S.unAimedC1.rightArm, Linear, 0.15)
3972 Blade:Destroy()
3973end
3974
3975--------------------[ GRENADE FUNCTIONS ]---------------------------------------------
3976
3977function CreateGrenade(Type)
3978 local Grenade = Instance.new("Model")
3979 Grenade.Name = "Grenade"
3980
3981 local Center = Instance.new("Part")
3982 Center.BrickColor = (Type == 1 and S.LethalGrenadeColor or S.TacticalGrenadeColor)
3983 Center.Name = "Center"
3984 Center.CanCollide = false
3985 Center.Elasticity = 0
3986 Center.FormFactor = Enum.FormFactor.Custom
3987 Center.Size = S.GrenadeSize
3988 Center.BottomSurface = Enum.SurfaceType.Smooth
3989 Center.TopSurface = Enum.SurfaceType.Smooth
3990 Center.Parent = Grenade
3991
3992 local Mesh1 = Instance.new("SpecialMesh")
3993 Mesh1.MeshType = Enum.MeshType.Sphere
3994 Mesh1.Parent = Center
3995
3996 return Grenade
3997end
3998
3999function CreateTarget()
4000 local Target = Instance.new("Model")
4001
4002 local Center = Instance.new("Part")
4003 Center.BrickColor = BrickColor.new("Bright red")
4004 Center.Material = Enum.Material.SmoothPlastic
4005 Center.Transparency = 0.3
4006 Center.Name = "Center"
4007 Center.Anchored = true
4008 Center.CanCollide = false
4009 Center.FormFactor = Enum.FormFactor.Custom
4010 Center.Size = V3(4, 0.2, 4)
4011 Center.Parent = Target
4012 local CylinderMesh = Instance.new("CylinderMesh")
4013 CylinderMesh.Parent = Center
4014
4015 local Line = Instance.new("Part")
4016 Line.BrickColor = BrickColor.new("Bright red")
4017 Line.Transparency = 0.3
4018 Line.Name = "Line"
4019 Line.CFrame = Center.CFrame * CFrame.new(0, 5.1, 0)
4020 Line.Anchored = true
4021 Line.CanCollide = false
4022 Line.FormFactor = Enum.FormFactor.Custom
4023 Line.Size = V3(0.4, 10, 0.4)
4024 Line.BottomSurface = Enum.SurfaceType.Smooth
4025 Line.TopSurface = Enum.SurfaceType.Smooth
4026 Line.Parent = Target
4027
4028 return Target
4029end
4030
4031function ThrowGrenade(Type)
4032 local Speed = (
4033 Type == 1 and
4034 (S.LethalGrenadeType == 3 and S.LethalAnimationTime / 1.5 or S.LethalAnimationTime / 2)
4035 or S.TacticalAnimationTime / 2
4036 )
4037 local Grenade0 = nil
4038 if S.TrajectoryAssist then
4039 spawn(function()
4040 local X = 0
4041 local Vel = (Type == 1 and S.LethalGrenadeThrowVelocity or S.TacticalGrenadeThrowVelocity)
4042
4043 local GetX = function(Ang, T)
4044 local Vx = Vel * math.cos(Ang)
4045 return Vx * T
4046 end
4047
4048 local GetY = function(Ang, T)
4049 local V0y = Vel * math.sin(Ang)
4050 local Vy = V0y + (-196.2 * T)
4051 return (Vy * T) - (-98.1 * T * T)
4052 end
4053
4054 local Target = CreateTarget()
4055 Target.Parent = Cam
4056 Target.PrimaryPart = Target:WaitForChild("Center")
4057
4058 while (Keys[S.Keys.lethalGrenade] or Keys[S.Keys.tacticalGrenade]) and Selected do
4059 X = X + math.rad(10)
4060 for _,v in pairs(Target:GetChildren()) do
4061 v.Transparency = 0.2 + ((math.sin(X) + 1) / 5)
4062 end
4063
4064 local Lines = {}
4065 local LastX, LastY = nil, nil
4066 for T = 0, 10, 0.1 do
4067 local XPos = GetX(math.rad(7) - camAng.y, T)
4068 local YPos = GetY(math.rad(7) - camAng.y, T)
4069 if LastX and LastY then
4070 local LookV3 = HRP.CFrame.lookVector
4071 local LastPos = (Head.CFrame * CF(1.5, 0, 0)).p + (LookV3 * LastX) + V3(0, LastY, 0)
4072 local NewPos = (Head.CFrame * CF(1.5, 0, 0)).p + (LookV3 * XPos) + V3(0, YPos, 0)
4073 local LineCF = CF(LastPos, NewPos)
4074 local Dist = (LastPos - NewPos).magnitude
4075 local NewDist = Dist
4076
4077 local H, P = AdvRayCast(LastPos, (NewPos - LastPos), 1, {Cam, unpack(Ignore)})
4078 if H then
4079 NewDist = (P - LastPos).magnitude
4080
4081 local SurfaceCF = GetHitSurfaceCFrame(P, H)
4082 local SurfaceDir = CF(H.CFrame.p, SurfaceCF.p)
4083 local SurfaceDist = SurfaceDir.lookVector * (H.CFrame.p - SurfaceCF.p).magnitude / 2
4084 local SurfaceOffset = P - SurfaceCF.p + SurfaceDist
4085 local SurfaceCFrame = SurfaceDir + SurfaceDist + SurfaceOffset
4086
4087 Target:SetPrimaryPartCFrame(SurfaceCFrame * CFANG(RAD(-90), 0, 0))
4088
4089 Target.Parent = Cam
4090 else
4091 Target.Parent = nil
4092 end
4093
4094 local Line = Instance.new("Part")
4095 Line.BrickColor = BrickColor.Red()
4096 Line.Material = Enum.Material.SmoothPlastic
4097 Line.Transparency = 0.2 + ((math.sin(X) + 1) / 5)
4098 Line.Anchored = true
4099 Line.CanCollide = false
4100 Line.FormFactor = Enum.FormFactor.Custom
4101 Line.Size = Vector3.new(0.4, 0.4, NewDist)
4102 Line.TopSurface = Enum.SurfaceType.Smooth
4103 Line.BottomSurface = Enum.SurfaceType.Smooth
4104 Line.CFrame = LineCF + (LineCF.lookVector * NewDist / 2)
4105 Line.Parent = Cam
4106
4107 table.insert(Lines, Line)
4108
4109 LastX,LastY = XPos,YPos
4110
4111 if H then break end
4112 else
4113 LastX,LastY = XPos,YPos
4114 end
4115 end
4116
4117 RS.RenderStepped:wait()
4118
4119 for _,Line in pairs(Lines) do
4120 Line:Destroy()
4121 end
4122 end
4123
4124 Target:Destroy()
4125 end)
4126 end
4127
4128 local AnimTable = {
4129 function()
4130 tweenJoint(LWeld, CF(-1.5, 0, 0), CF(0, 0.6, 0), Linear, 0.2 * Speed)
4131 tweenJoint(RWeld, CF(1.5, 0, 0) * CFANG(0, 0, RAD(-10)), CF(0, 0.6, 0), Linear, 0.2 * Speed)
4132 tweenJoint(Grip, Grip.C0, CFANG(0, RAD(10), 0), Linear, 0.2 * Speed)
4133 wait(0.3 * Speed)
4134 end;
4135
4136 function()
4137 Grip.Part0 = Torso
4138 Grip.C1 = CF(-1, 0.5, -0.5)
4139
4140 if S.LethalGrenadeType == 3 and Type == 1 then
4141 Grenade0 = CreateKnife()
4142 Grenade0.Parent = grenadeFolder
4143
4144 local Weld = Instance.new("Weld")
4145 Weld.Part0 = fakeRArm
4146 Weld.Part1 = Grenade0:WaitForChild("Center")
4147 Weld.C0 = Grip.C0
4148 Weld.C1 = CF(0, 0, -0.5) * CFANG(RAD(90), RAD(90), 0)
4149 Weld.Parent = Grenade0:WaitForChild("Center")
4150
4151 tweenJoint(LWeld2, CF(), CF(), Sine, 0.3 * Speed)
4152 tweenJoint(RWeld2, CF(), CF(), Sine, 0.3 * Speed)
4153 tweenJoint(LWeld, armC0[1], CF(0, 0.5, 0.1) * CFANG(RAD(90), 0, 0), Sine, 0.3 * Speed)
4154 tweenJoint(RWeld, armC0[2], CF(0, 0.4, 0.1) * CFANG(RAD(-80), 0, 0), Sine, 0.3 * Speed)
4155 wait(0.3 * Speed)
4156 else
4157 Grenade0 = CreateGrenade(Type)
4158 Grenade0.Parent = grenadeFolder
4159
4160 local Weld = Instance.new("Weld")
4161 Weld.Part0 = fakeRArm
4162 Weld.Part1 = Grenade0:WaitForChild("Center")
4163 Weld.C0 = Grip.C0
4164 Weld.Parent = Grenade0:WaitForChild("Center")
4165
4166 tweenJoint(LWeld2, CF(), CFANG(0, RAD(80), 0), Linear, 0.25 * Speed)
4167 tweenJoint(RWeld2, CF(), CFANG(0, RAD(-80), 0), Linear, 0.25 * Speed)
4168 tweenJoint(LWeld, armC0[1], CF(-0.2, 0.8, 0.1) * CFANG(RAD(10), 0, RAD(-30)), Linear, 0.25 * Speed)
4169 tweenJoint(RWeld, armC0[2], CF(0.2, 0.8, 0.1) * CFANG(RAD(10), 0, RAD(30)), Linear, 0.25 * Speed)
4170 wait(0.3 * Speed)
4171 end
4172 end;
4173
4174 function()
4175 repeat wait() until (not Keys[S.Keys.lethalGrenade]) and (not Keys[S.Keys.tacticalGrenade]) or (not Selected)
4176 end;
4177
4178 function()
4179 if S.LethalGrenadeType ~= 3 or Type == 2 then
4180 tweenJoint(LWeld2, CF(), CFANG(0, RAD(45), 0), Sine, 0.2 * Speed)
4181 tweenJoint(RWeld2, CF(), CFANG(0, RAD(-45), 0), Sine, 0.2 * Speed)
4182 tweenJoint(LWeld, armC0[1], CF(0, 0.8, 0.1), Sine, 0.2 * Speed)
4183 tweenJoint(RWeld, armC0[2], CF(0, 0.8, 0.1), Sine, 0.2 * Speed)
4184 wait(0.2 * Speed)
4185 end
4186 end;
4187
4188 function()
4189 if S.LethalGrenadeType ~= 3 or Type == 2 then
4190 tweenJoint(LWeld2, CF(), CF(), Sine, 0.3 * Speed)
4191 tweenJoint(RWeld2, CF(), CF(), Sine, 0.3 * Speed)
4192 tweenJoint(LWeld, armC0[1], CF(0, 0.5, 0.1) * CFANG(RAD(90), 0, 0), Sine, 0.3 * Speed)
4193 tweenJoint(RWeld, armC0[2], CF(0, 0.4, 0.1) * CFANG(RAD(-80), 0, 0), Sine, 0.3 * Speed)
4194 wait(0.3 * Speed)
4195 end
4196 end;
4197
4198 function()
4199 tweenJoint(RWeld, armC0[2], CF(0, 0.8, 0.1) * CFANG(RAD(-10), 0, 0), Sine, 0.1 * Speed)
4200 wait(0.07 * Speed)
4201 end;
4202
4203 function()
4204 local Main = nil
4205 Grenade0:Destroy()
4206
4207 if S.LethalGrenadeType == 3 and Type == 1 then
4208 local Grenade1 = CreateKnife()
4209 Main = Grenade1:WaitForChild("Center")
4210
4211 Grenade1.Parent = grenadeFolder
4212
4213 Main.CFrame = fakeRArm.CFrame * Grip.C0 * CF(0, 0.5, 0) * CFANG(RAD(-90), 0, RAD(90))
4214 Main.Velocity = Main.Velocity + ((Head.CFrame * CFANG(RAD(7), 0, 0)).lookVector * S.LethalGrenadeThrowVelocity)
4215 Main.RotVelocity = (Main.CFrame * CFANG(RAD(90), 0, 0)).lookVector * 20
4216 else
4217 local Grenade1 = CreateGrenade(Type)
4218 Main = Grenade1:WaitForChild("Center")
4219
4220 local Sound = Instance.new("Sound")
4221 Sound.SoundId = (
4222 Type == 1 and "rbxassetid://180302005"
4223 or "rbxassetid://156283116"
4224 )
4225 Sound.Volume = 1
4226 Sound.Parent = Main
4227
4228 Grenade1.Parent = grenadeFolder
4229
4230 Main.CanCollide = true
4231 Main.CFrame = fakeRArm.CFrame * Grip.C0
4232 if Type == 1 then
4233 Main.Velocity = Main.Velocity + ((Head.CFrame * CFANG(RAD(7), 0, 0)).lookVector * S.LethalGrenadeThrowVelocity)
4234 elseif Type == 2 then
4235 Main.Velocity = Main.Velocity + ((Head.CFrame * CFANG(RAD(7), 0, 0)).lookVector * S.TacticalGrenadeThrowVelocity)
4236 end
4237 end
4238
4239 spawn(function()
4240 if Type == 1 then
4241 if S.LethalGrenadeType == 1 then
4242 local Frag_Main = Grenade_Scripts:WaitForChild("Frag_Main"):Clone()
4243
4244 Frag_Main.Parent = Main.Parent
4245
4246 local Plyr = Frag_Main:WaitForChild("Plyr")
4247 local GetSettings = Frag_Main:WaitForChild("GetSettings")
4248
4249 Plyr.Value = Player
4250 function GetSettings.OnClientInvoke()
4251 local Settings = {
4252 AllowFriendlyFire = S.AllowFriendlyFire;
4253 CanDamageNPCs = S.CanDamageNPCs;
4254 DetonationTime = S.DetonationTime;
4255 TimerStartOnHit = S.TimerStartOnHit;
4256 GrenadeBlastRadius = S.GrenadeBlastRadius;
4257 GrenadeBlastPressure = S.GrenadeBlastPressure;
4258 GrenadeExplosionType = S.GrenadeExplosionType;
4259 LethalGrenadeDamage = S.LethalGrenadeDamage;
4260 GrenadeRayCastDamage = S.GrenadeRayCastDamage;
4261 GrenadeRangeBasedDamage = S.GrenadeRangeBasedDamage;
4262 ShockwaveColor = S.ShockwaveColor;
4263 ShockwaveDuration = S.ShockwaveDuration;
4264 IgnoreCode = ignoreCode.Value;
4265 }
4266 return Settings
4267 end
4268
4269 Frag_Main.Disabled = false
4270 elseif S.LethalGrenadeType == 2 then
4271 local Semtex_Main = Grenade_Scripts:WaitForChild("Semtex_Main"):Clone()
4272
4273 Semtex_Main.Parent = Main.Parent
4274
4275 local Plyr = Semtex_Main:WaitForChild("Plyr")
4276 local GetSettings = Semtex_Main:WaitForChild("GetSettings")
4277
4278 Plyr.Value = Player
4279 function GetSettings.OnClientInvoke()
4280 local Settings = {
4281 AllowFriendlyFire = S.AllowFriendlyFire;
4282 CanDamageNPCs = S.CanDamageNPCs;
4283 DetonationTime = S.DetonationTime;
4284 TimerStartOnHit = S.TimerStartOnHit;
4285 GrenadeBlastRadius = S.GrenadeBlastRadius;
4286 GrenadeBlastPressure = S.GrenadeBlastPressure;
4287 GrenadeExplosionType = S.GrenadeExplosionType;
4288 LethalGrenadeDamage = S.LethalGrenadeDamage;
4289 GrenadeRayCastDamage = S.GrenadeRayCastDamage;
4290 GrenadeRangeBasedDamage = S.GrenadeRangeBasedDamage;
4291 ShockwaveColor = S.ShockwaveColor;
4292 ShockwaveDuration = S.ShockwaveDuration;
4293 IgnoreCode = ignoreCode.Value;
4294 }
4295 return Settings
4296 end
4297
4298 Semtex_Main.Disabled = false
4299 elseif S.LethalGrenadeType == 3 then
4300 local Knife_Main = Grenade_Scripts:WaitForChild("Knife_Main"):Clone()
4301
4302 Knife_Main.Parent = Main
4303
4304 local Plyr = Knife_Main:WaitForChild("Plyr")
4305 local GetSettings = Knife_Main:WaitForChild("GetSettings")
4306
4307 Plyr.Value = Player
4308 function GetSettings.OnClientInvoke()
4309 local Settings = {
4310 AllowFriendlyFire = S.AllowFriendlyFire;
4311 CanDamageNPCs = S.CanDamageNPCs;
4312 IgnoreCode = ignoreCode.Value;
4313 }
4314 return Settings
4315 end
4316
4317 Knife_Main.Disabled = false
4318 elseif S.LethalGrenadeType == 4 then
4319 local Molotov_Main = Grenade_Scripts:WaitForChild("Molotov_Main"):Clone()
4320
4321 Molotov_Main.Parent = Main.Parent
4322
4323 local Plyr = Molotov_Main:WaitForChild("Plyr")
4324 local GetSettings = Molotov_Main:WaitForChild("GetSettings")
4325
4326 Plyr.Value = Player
4327 function GetSettings.OnClientInvoke()
4328 local Settings = {
4329 AllowFriendlyFire = S.AllowFriendlyFire;
4330 CanDamageNPCs = S.CanDamageNPCs;
4331 DetonationTime = S.DetonationTime;
4332 GrenadeBlastRadius = S.GrenadeBlastRadius;
4333 LethalGrenadeDamage = S.LethalGrenadeDamage;
4334 IgnoreCode = ignoreCode.Value;
4335 }
4336 return Settings
4337 end
4338
4339 Molotov_Main.Disabled = false
4340 end
4341 elseif Type == 2 then
4342 if S.TacticalGrenadeType == 1 then
4343 local Smoke_Main = Grenade_Scripts:WaitForChild("Smoke_Main"):Clone()
4344
4345 Smoke_Main.Parent = Main.Parent
4346
4347 local Plyr = Smoke_Main:WaitForChild("Plyr")
4348 local GetSettings = Smoke_Main:WaitForChild("GetSettings")
4349
4350 Plyr.Value = Player
4351 function GetSettings.OnClientInvoke()
4352 local Settings = {
4353 DetonationTime = S.DetonationTime;
4354 TimerStartOnHit = S.TimerStartOnHit;
4355 GrenadeEffectRadius = S.GrenadeEffectRadius;
4356 GrenadeEffectTime = S.GrenadeEffectTime;
4357 ShockwaveColor = S.ShockwaveColor;
4358 ShockwaveDuration = S.ShockwaveDuration;
4359 IgnoreCode = ignoreCode.Value;
4360 }
4361 return Settings
4362 end
4363
4364 Smoke_Main.Disabled = false
4365 elseif S.TacticalGrenadeType == 2 then
4366 local Flash_Main = Grenade_Scripts:WaitForChild("Flash_Main"):Clone()
4367
4368 Flash_Main.Parent = Main.Parent
4369
4370 local Plyr = Flash_Main:WaitForChild("Plyr")
4371 local GetSettings = Flash_Main:WaitForChild("GetSettings")
4372
4373 Plyr.Value = Player
4374 function GetSettings.OnClientInvoke()
4375 local Settings = {
4376 DetonationTime = S.DetonationTime;
4377 TimerStartOnHit = S.TimerStartOnHit;
4378 GrenadeEffectRadius = S.GrenadeEffectRadius;
4379 GrenadeEffectTime = S.GrenadeEffectTime;
4380 IgnoreCode = ignoreCode.Value;
4381 }
4382 return Settings
4383 end
4384
4385 Flash_Main.Disabled = false
4386 end
4387 end
4388 end)
4389
4390 local Trail_Main = Grenade_Scripts:WaitForChild("Trail_Main"):Clone()
4391
4392 Trail_Main.Parent = Main.Parent
4393
4394 local Plyr = Trail_Main:WaitForChild("Plyr")
4395 local GetSettings = Trail_Main:WaitForChild("GetSettings")
4396
4397 Plyr.Value = Player
4398 function GetSettings.OnClientInvoke()
4399 local Settings = {
4400 GrenadeTrail = S.GrenadeTrail;
4401 GrenadeTransparency = S.GrenadeTransparency;
4402 GrenadeTrailColor = S.GrenadeTrailColor;
4403 GrenadeTrailTransparency = S.GrenadeTrailTransparency;
4404 GrenadeTrailThickness = S.GrenadeTrailThickness;
4405 GrenadeTrailVisibleTime = S.GrenadeTrailVisibleTime;
4406 GrenadeTrailDisappearTime = S.GrenadeTrailDisappearTime;
4407 }
4408 return Settings
4409 end
4410
4411 Trail_Main.Disabled = false
4412
4413 wait(0.2 * Speed)
4414 end;
4415
4416 function()
4417 tweenJoint(RWeld, CF(1.5, 0, 0) * CFANG(0, 0, RAD(-10)), CF(0, 0.6, 0), Linear, 0.2 * Speed)
4418 wait(0.3 * Speed)
4419 end;
4420
4421 function()
4422 Grip.Part0 = RArm
4423 Grip.C1 = S.unAimedC1.Grip
4424
4425 tweenJoint(LWeld, armC0[1], S.unAimedC1.leftArm, Linear, 0.2 * Speed)
4426 tweenJoint(RWeld, armC0[2], S.unAimedC1.rightArm, Linear, 0.2 * Speed)
4427 wait(0.2 * Speed)
4428 end;
4429 }
4430
4431 for _,F in pairs(AnimTable) do
4432 if (not Selected) then
4433 break
4434 end
4435 F()
4436 end
4437
4438 if (not Selected) and Grenade0 then
4439 Grenade0:Destroy()
4440 end
4441end
4442
4443--------------------[ CAMERA STEADYING FUNCTIONS ]------------------------------------
4444
4445function steadyCamera()
4446 scopeSteady.Text = "Steadying..."
4447 scopeSteady.TextColor3 = Color3.new(1, 1, 0)
4448 camSteady = true
4449 local originalSway = camSway
4450 local Increment = 1.5 / 0.6
4451 local X = 0
4452 while true do
4453 RS.RenderStepped:wait()
4454 local newX = X + Increment
4455 X = (newX > 90 and 90 or newX)
4456 if (not steadyKeyPressed) then break end
4457 camSway = numLerp(originalSway, 0, Sine(X))
4458 if X == 90 then break end
4459 end
4460 while steadyKeyPressed and Aimed do
4461 if currentSteadyTime > 0 then
4462 local NewSteadyTime = currentSteadyTime - 1
4463 currentSteadyTime = (NewSteadyTime < 0 and 0 or NewSteadyTime)
4464 camSway = 0
4465 elseif currentSteadyTime == 0 then
4466 break
4467 end
4468 RS.RenderStepped:wait()
4469 end
4470 camSteady = false
4471 spawn(function()
4472 local Increment = 1.5 / 0.25
4473 local X = 0
4474 while true do
4475 RS.RenderStepped:wait()
4476 local newX = X + Increment
4477 X = (newX > 90 and 90 or newX)
4478 if camSteady then break end
4479 camSway = numLerp(0, S.scopeSettings.camSwayOnBreath, 1 - COS(RAD(X)))
4480 if X == 90 then break end
4481 end
4482 Increment = 1.5 / S.scopeSettings.breathTime
4483 X = 0
4484 while true do
4485 RS.RenderStepped:wait()
4486 local newX = X + Increment
4487 X = (newX > 90 and 90 or newX)
4488 if camSteady then break end
4489 camSway = numLerp(S.scopeSettings.camSwayOnBreath, 1, Sine(X))
4490 if X == 90 then break end
4491 end
4492 --[[for X = 0, 90, 1.5 / 0.2 do
4493 local Alpha = 1 - COS(RAD(X))--math.log10(X) / math.log10(90)
4494 camSway = numLerp(0, 3, Alpha)
4495 RS.RenderStepped:wait()
4496 end]]
4497 --[[for X = 0, 90, 1.5 / S.scopeSettings.steadyTime do
4498 if camSteady then break end
4499 local Alpha = SIN(RAD(X))
4500 camSway = numLerp(3, 1, Alpha)
4501 RS.RenderStepped:wait()
4502 end]]
4503 end)
4504 retakeBreath()
4505end
4506
4507function retakeBreath()
4508 scopeSteady.Text = "Re-taking Breath"
4509 scopeSteady.TextColor3 = Color3.new(1, 0, 0)
4510 takingBreath = true
4511 local Increment = S.scopeSettings.steadyTime / S.scopeSettings.breathTime
4512 while takingBreath do
4513 if currentSteadyTime < maxSteadyTime then
4514 local newSteadyTime = currentSteadyTime + Increment
4515 currentSteadyTime = (newSteadyTime > maxSteadyTime and maxSteadyTime or newSteadyTime)
4516 elseif currentSteadyTime >= maxSteadyTime then
4517 break
4518 end
4519 RS.RenderStepped:wait()
4520 end
4521 if takingBreath then
4522 scopeSteady.Text = "Hold "..convertKey(S.Keys.scopeSteady).." to Steady"
4523 scopeSteady.TextColor3 = Color3.new(1, 1, 0)
4524 takingBreath = false
4525 end
4526end
4527
4528--------------------[ SPRINTING FUNCTIONS ]-------------------------------------------
4529
4530function canRun(midRun)
4531 return ((Forward and (not Backward)) and
4532 Walking and (Stamina > 0) and Running and
4533 Selected and (midRun and true or onGround) and
4534 runReady and (S.canFireWhileRunning and true or (not Firing))
4535 )
4536end
4537
4538function monitorStamina()
4539 Running = true
4540 if (not canRun(false)) then
4541 Running = false
4542 return
4543 end
4544 if Aimed then unAimGun(true) end
4545 if Stance == 1 or Stance == 2 then Stand() end
4546 if (not (Reloading and S.reloadSettings.Anim)) then
4547 if S.canFireWhileRunning then
4548 tweenJoint(LWeld, armC0[1], S.unAimedC1.leftArm, Sine, 0.4)
4549 tweenJoint(RWeld, armC0[2], S.unAimedC1.rightArm, Sine, 0.4)
4550 tweenJoint(Grip, nil, S.unAimedC1.Grip, Sine, 0.4)
4551 else
4552 tweenJoint(LWeld, armC0[1], S.runningC1.leftArm, Sine, 0.4)
4553 tweenJoint(RWeld, armC0[2], S.runningC1.rightArm, Sine, 0.4)
4554 tweenJoint(Grip, nil, S.runningC1.Grip, Sine, 0.4)
4555 end
4556 end
4557 crossOffset = 50
4558 while runKeyPressed do
4559 if canRun(true) then
4560 if onGround then
4561 local newStamina = Stamina - 1
4562 Stamina = (newStamina < 0 and 0 or newStamina)
4563 end
4564 else
4565 break
4566 end
4567 RS.RenderStepped:wait()
4568 end
4569 Running = false
4570 if (not Aimed) and (not (Reloading and S.reloadSettings.Anim)) and (not S.canFireWhileRunning) then
4571 crossOffset = 0
4572 tweenJoint(LWeld, armC0[1], S.unAimedC1.leftArm, Sine, 0.4)
4573 tweenJoint(RWeld, armC0[2], S.unAimedC1.rightArm, Sine, 0.4)
4574 tweenJoint(Grip, nil, S.unAimedC1.Grip, Sine, 0.4)
4575 end
4576
4577 rechargeStamina()
4578end
4579
4580function rechargeStamina()
4581 chargingStamina = true
4582 while ((not runKeyPressed) or (Stamina < maxStamina)) and (not Running) do
4583 if Stamina < maxStamina then
4584 local newStamina = Stamina + (S.sprintTime / S.staminaCoolTime)
4585 Stamina = (newStamina > maxStamina and maxStamina or newStamina)
4586 elseif Stamina >= maxStamina then
4587 break
4588 end
4589 RS.RenderStepped:wait()
4590 end
4591 chargingStamina = false
4592end
4593
4594--------------------[ STANCE FUNCTIONS ]----------------------------------------------
4595
4596function Stand(onDeselected)
4597 local LHip = Torso["Left Hip"]
4598 local RHip = Torso["Right Hip"]
4599 LLegWeld.Part1 = nil
4600 LHip.Part1 = LLeg
4601 RLegWeld.Part1 = nil
4602 RHip.Part1 = RLeg
4603 Stance = 0
4604 spreadStance = "Stand"
4605 baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion]
4606 if S.stanceSettings.Anim and (not onDeselected) then
4607 spawn(function()
4608 local prevStanceSway = stanceSway
4609 local X = 0
4610 local Increment = 1.5 / S.stanceSettings.Speed
4611 while true do
4612 RS.RenderStepped:wait()
4613 local newX = X + Increment
4614 X = (newX > 90 and 90 or newX)
4615 if Stance ~= 0 then break end
4616 stanceSway = numLerp(prevStanceSway, 1, Sine(X))
4617 if X == 90 then break end
4618 end
4619 end)
4620 tweenJoint(ABWeld, CF(), nil, Sine, S.stanceSettings.Speed)
4621 tweenJoint(LLegWeld, legC0.Stand[1], nil, Sine, S.stanceSettings.Speed)
4622 tweenJoint(RLegWeld, legC0.Stand[2], nil, Sine, S.stanceSettings.Speed)
4623 tweenJoint(LHip, CF(-1, -1, 0) * CFANG(0, RAD(-90), 0), CF(-0.5, 1, 0) * CFANG(0, RAD(-90), 0), Sine, S.stanceSettings.Speed)
4624 tweenJoint(RHip, CF(1, -1, 0) * CFANG(RAD(-180), RAD(90), 0), CF(0.5, 1, 0) * CFANG(RAD(-180), RAD(90), 0), Sine, S.stanceSettings.Speed)
4625 tweenJoint(Root, CFANG(RAD(-90), 0, RAD(180)), nil, Sine, S.stanceSettings.Speed)
4626 tweenJoint(headWeld, CF(0, 1.5, 0), nil, Sine, S.stanceSettings.Speed)
4627 elseif onDeselected or (not S.stanceSettings.Anim) then
4628 ABWeld.C0 = CF()
4629 LLegWeld.C0 = legC0.Stand[1]
4630 RLegWeld.C0 = legC0.Stand[2]
4631 LHip.C0, LHip.C1 = CF(-1, -1, 0) * CFANG(0, RAD(-90), 0), CF(-0.5, 1, 0) * CFANG(0, RAD(-90), 0)
4632 RHip.C0, RHip.C1 = CF(1, -1, 0) * CFANG(RAD(-180), RAD(90), 0), CF(0.5, 1, 0) * CFANG(RAD(-180), RAD(90), 0)
4633 Root.C0 = CFANG(RAD(-90), 0, RAD(180))
4634 headWeld.C0 = CF(0, 1.5, 0)
4635 end
4636end
4637
4638function Crouch()
4639 local LHip = Torso["Left Hip"]
4640 local RHip = Torso["Right Hip"]
4641 LHip.Part1 = nil
4642 LLegWeld.Part1 = LLeg
4643 RHip.Part1 = nil
4644 RLegWeld.Part1 = RLeg
4645 Stance = 1
4646 spreadStance = "Crouch"
4647 baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion]
4648 if S.stanceSettings.Anim then
4649 spawn(function()
4650 local prevStanceSway = stanceSway
4651 local X = 0
4652 local Increment = 1.5 / S.stanceSettings.Speed
4653 while true do
4654 RS.RenderStepped:wait()
4655 local newX = X + Increment
4656 X = (newX > 90 and 90 or newX)
4657 if Stance ~= 1 then break end
4658 stanceSway = numLerp(prevStanceSway, 0.75, Sine(X))
4659 if X == 90 then break end
4660 end
4661 end)
4662 tweenJoint(ABWeld, CF(0, 0, -0.05), nil, Sine, S.stanceSettings.Speed)
4663 tweenJoint(LLegWeld, legC0.Crouch[1], nil, Sine, S.stanceSettings.Speed)
4664 tweenJoint(RLegWeld, legC0.Crouch[2], nil, Sine, S.stanceSettings.Speed)
4665 tweenJoint(LHip, CF(-1, -0.5, 0) * CFANG(0, RAD(-90), 0), CF(-0.5, 0.5, 1) * CFANG(0, RAD(-90), RAD(-90)), Sine, S.stanceSettings.Speed)
4666 tweenJoint(RHip, CF(1, -0.5, 0.25) * CFANG(RAD(-180), RAD(90), 0), CF(0.5, 0.5, 1) * CFANG(RAD(-180), RAD(90), 0), Sine, S.stanceSettings.Speed)
4667 tweenJoint(Root, CF(0, -1, 0) * CFANG(RAD(-90), 0, RAD(180)), nil, Sine, S.stanceSettings.Speed)
4668 tweenJoint(headWeld, CF(0, 1.5, 0), nil, Sine, S.stanceSettings.Speed)
4669 else
4670 ABWeld.C0 = CF(0, 0, -1 / 16)
4671 LLegWeld.C0 = legC0.Crouch[1]
4672 RLegWeld.C0 = legC0.Crouch[2]
4673 LHip.C0, LHip.C1 = CF(-1, -0.5, 0) * CFANG(0, RAD(-90), 0), CF(-0.5, 0.5, 1) * CFANG(0, RAD(-90), RAD(-90))
4674 RHip.C0, RHip.C1 = CF(1, -0.5, 0.25) * CFANG(RAD(-180), RAD(90), 0), CF(0.5, 0.5, 1) * CFANG(RAD(-180), RAD(90), 0)
4675 Root.C0 = CF(0, -1, 0) * CFANG(RAD(-90), 0, RAD(180))
4676 headWeld.C0 = CF(0, 1.5, 0)
4677 end
4678end
4679
4680function Prone()
4681 local LHip = Torso["Left Hip"]
4682 local RHip = Torso["Right Hip"]
4683 LHip.Part1 = nil
4684 LLegWeld.Part1 = LLeg
4685 RHip.Part1 = nil
4686 RLegWeld.Part1 = RLeg
4687 Stance = 2
4688 spreadStance = "Prone"
4689 baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion]
4690 if S.stanceSettings.Anim then
4691 spawn(function()
4692 local prevStanceSway = stanceSway
4693 local X = 0
4694 local Increment = 1.5 / S.stanceSettings.Speed
4695 while true do
4696 RS.RenderStepped:wait()
4697 local newX = X + Increment
4698 X = (newX > 90 and 90 or newX)
4699 if Stance ~= 2 then break end
4700 stanceSway = numLerp(prevStanceSway, 0.5, Sine(X))
4701 if X == 90 then break end
4702 end
4703 end)
4704 tweenJoint(ABWeld, CF(0, 0, -0.1), nil, Sine, S.stanceSettings.Speed)
4705 tweenJoint(LLegWeld, legC0.Prone[1], nil, Sine, S.stanceSettings.Speed)
4706 tweenJoint(RLegWeld, legC0.Prone[2], nil, Sine, S.stanceSettings.Speed)
4707 tweenJoint(Root, CF(0, -2.5, 1) * CFANG(RAD(180), 0, RAD(180)), nil, Sine, S.stanceSettings.Speed)
4708 tweenJoint(headWeld, CF(0, 1, 1) * CFANG(RAD(90), 0, 0), nil, Sine, S.stanceSettings.Speed)
4709 else
4710 ABWeld.C0 = CF(0, 0, -1 / 8)
4711 LLegWeld.C0 = legC0.Prone[1]
4712 RLegWeld.C0 = legC0.Prone[2]
4713 Root.C0 = CF(0, -2.5, 1) * CFANG(RAD(180), 0, RAD(180))
4714 headWeld.C0 = CF(0, 1, 1) * CFANG(RAD(90), 0, 0)
4715 end
4716end
4717
4718function Dive()
4719 onGround = false
4720 local diveDirection = (HRP.CFrame * CFANG(S.diveSettings.Angle, 0, 0)).lookVector * S.walkSpeeds.Sprinting * S.diveSettings.Force
4721 local BF = Instance.new("BodyForce")
4722 BF.force = diveDirection + Vector3.new(0, playerMass * 196.2, 0)
4723 BF.Parent = HRP
4724 --[[spawn(function()
4725 HRP.Velocity = HRP.CFrame.lookVector * 60 + V3(0, 40, 0)
4726 wait(0.1)
4727 HRP.Velocity = HRP.CFrame.lookVector * 70 + V3(0, 30, 0)
4728 wait(0.4)
4729 HRP.Velocity = HRP.CFrame.lookVector * 30 + V3(0, -10, 0)
4730 end)]]
4731 delay(0.05, function()
4732 spawn(function()
4733 while true do
4734 local newRay = Ray.new(HRP.Position, V3(0, -3.1, 0))
4735 local H, _ = workspace:FindPartOnRayWithIgnoreList(newRay, Ignore)
4736 if H then
4737 onGround = true
4738 break
4739 end
4740 wait()
4741 end
4742 end)
4743 Prone()
4744 wait(0.1)
4745 BF:Destroy()
4746 end)
4747end
4748
4749--------------------[ MOUSE FUNCTIONS ]-----------------------------------------------
4750
4751function onMB1Down()
4752 MB1Down = true
4753 firstShot = true
4754 if fireFunction then
4755 fireFunction()
4756 end
4757end
4758
4759function onMB1Up()
4760 MB1Down = false
4761 lowerSpread()
4762end
4763
4764function onMB2Down()
4765 if S.aimSettings.holdToADS then
4766 if (not AimingIn) and (not Aimed) then
4767 AimingIn = true
4768 aimGun()
4769 AimingIn = false
4770 end
4771 else
4772 if Aimed then
4773 unAimGun()
4774 else
4775 aimGun()
4776 end
4777 end
4778end
4779
4780function onMB2Up()
4781 if S.aimSettings.holdToADS then
4782 if (not AimingOut) and Aimed then
4783 AimingOut = true
4784 unAimGun()
4785 AimingOut = false
4786 end
4787 end
4788end
4789
4790function onScrollUp()
4791 local newAimSensitivity = aimSensitivity + S.sensitivitySettings.Increment
4792 aimSensitivity = (
4793 newAimSensitivity < S.sensitivitySettings.Min and S.sensitivitySettings.Min or
4794 newAimSensitivity > S.sensitivitySettings.Max and S.sensitivitySettings.Max or
4795 newAimSensitivity
4796 )
4797 mouseSensitivity = (Aimed and aimSensitivity or mouseSensitivity)
4798
4799 Sens.Text = "S: "..aimSensitivity
4800 if mainGUI:IsDescendantOf(game) then
4801 Sens.Visible = true
4802 local t0 = tick()
4803 lastSensUpdate = t0
4804
4805 wait(0.3)
4806
4807 if lastSensUpdate <= t0 then
4808 Sens.Visible = false
4809 end
4810 end
4811end
4812
4813function onScrollDown()
4814 local newAimSensitivity = aimSensitivity - S.sensitivitySettings.Increment
4815 aimSensitivity = (
4816 newAimSensitivity < S.sensitivitySettings.Min and S.sensitivitySettings.Min or
4817 newAimSensitivity > S.sensitivitySettings.Max and S.sensitivitySettings.Max or
4818 newAimSensitivity
4819 )
4820 mouseSensitivity = (Aimed and aimSensitivity or mouseSensitivity)
4821
4822 Sens.Text = "S: "..aimSensitivity
4823 if mainGUI:IsDescendantOf(game) then
4824 Sens.Visible = true
4825 local t0 = tick()
4826 lastSensUpdate = t0
4827
4828 wait(0.3)
4829
4830 if lastSensUpdate <= t0 then
4831 Sens.Visible = false
4832 end
4833 end
4834end
4835
4836--------------------[ KEYBOARD FUNCTIONS ]--------------------------------------------
4837
4838function keyDown(K)
4839 local Key = string.lower(K)
4840
4841 if Key == S.Keys.lowerStance and S.canChangeStance then
4842 if (not Running) then
4843 if Stance == 0 then
4844 if S.stanceSettings.Stances.Crouch then
4845 Crouch()
4846 elseif S.stanceSettings.Stances.Prone then
4847 Prone()
4848 end
4849 elseif Stance == 1 then
4850 if S.stanceSettings.Stances.Prone then
4851 Prone()
4852 end
4853 end
4854 elseif S.dolphinDive then
4855 wait()
4856 if Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall and (not UIS:IsKeyDown("Space")) and runReady then
4857 local tempConnection = Humanoid.Changed:connect(function()
4858 Humanoid.Jump = false
4859 end)
4860 runReady = false
4861 Dive()
4862 Running = false
4863 wait(S.diveSettings.rechargeTime)
4864 tempConnection:disconnect()
4865 runReady = true
4866 end
4867 end
4868 end
4869
4870 if Key == S.Keys.raiseStance and S.canChangeStance then
4871 if (not Running) then
4872 if Stance == 2 then
4873 if S.stanceSettings.Stances.Crouch then
4874 Crouch()
4875 else
4876 Stand()
4877 end
4878 elseif Stance == 1 then
4879 Stand()
4880 end
4881 end
4882 end
4883
4884 if Key == S.Keys.ADS then
4885 if S.aimSettings.holdToADS then
4886 if (not AimingIn) and (not Aimed) then
4887 AimingIn = true
4888 aimGun()
4889 AimingIn = false
4890 end
4891 else
4892 if Aimed then
4893 unAimGun()
4894 else
4895 aimGun()
4896 end
4897 end
4898 end
4899
4900 if Key == S.Keys.selectFire and S.selectFire then
4901 if canSelectFire then
4902 canSelectFire = false
4903 rawFireMode = rawFireMode + 1
4904 modeGUI.Text = Modes[((rawFireMode - 1) % numModes) + 1]
4905 if modeGUI.Text == "AUTO" then
4906 fireFunction = autoFire
4907 elseif modeGUI.Text == "BURST" then
4908 fireFunction = burstFire
4909 elseif modeGUI.Text == "SEMI" then
4910 fireFunction = semiFire
4911 else
4912 fireFunction = nil
4913 end
4914 local speedAlpha = S.selectFireSettings.animSpeed / 0.6
4915 if S.selectFireSettings.GUI then
4916 spawn(function()
4917 fireSelect.Visible = true
4918 local prevRawFireMode = rawFireMode
4919 local Increment = 1.5 / (speedAlpha * 0.25)
4920 local X = 0
4921 wait(speedAlpha * 0.1)
4922 while true do
4923 RS.RenderStepped:wait()
4924 local newX = X + Increment
4925 X = (newX > 90 and 90 or newX)
4926 if prevRawFireMode ~= rawFireMode then break end
4927 updateModeLabels(rawFireMode - 1, rawFireMode, X)
4928 if X == 90 then break end
4929 end
4930 wait(speedAlpha * 0.25)
4931 fireSelect.Visible = false
4932 end)
4933 end
4934 if S.selectFireSettings.Animation and (not Aimed) and (not isRunning) and (not isCrawling) then
4935 spawn(function()
4936 local sequenceTable = {
4937 function()
4938 tweenJoint(RWeld2, nil, CFANG(0, RAD(5), 0), Sine, speedAlpha * 0.15)
4939 tweenJoint(LWeld, armC0[1], CF(0.1, 1, -0.3) * CFANG(RAD(-7), 0, RAD(-65)), Linear, speedAlpha * 0.15)
4940 wait(speedAlpha * 0.2)
4941 end;
4942
4943 function()
4944 tweenJoint(LWeld, armC0[1], CF(0.1, 1, -0.3) * CFANG(RAD(-10), 0, RAD(-65)), Linear, speedAlpha * 0.1)
4945 wait(speedAlpha * 0.2)
4946 end;
4947
4948 function()
4949 tweenJoint(RWeld2, nil, CF(), Sine, speedAlpha * 0.2)
4950 tweenJoint(LWeld, armC0[1], S.unAimedC1.leftArm, Sine, speedAlpha * 0.2)
4951 wait(speedAlpha * 0.2)
4952 end;
4953 }
4954
4955 for _, F in pairs(sequenceTable) do
4956 if Aimed or isRunning or isCrawling or Reloading then
4957 break
4958 end
4959 F()
4960 end
4961 end)
4962 end
4963 if S.selectFireSettings.Animation or S.selectFireSettings.GUI then
4964 wait(S.selectFireSettings.animSpeed)
4965 end
4966 canSelectFire = true
4967 end
4968 end
4969
4970 if Key == S.Keys.Reload then
4971 if (not Reloading) and (not isCrawling) then
4972 Reload()
4973 end
4974 end
4975
4976
4977 --[[if Key == S.Keys.Knife and S.CanKnife then
4978 Knife()
4979 end
4980
4981 if Key == S.Keys.lethalGrenade and S.Throwables then
4982 if (not Knifing) and (not Running) and (not Aimed) and (not Aiming) and (not ThrowingGrenade) then
4983 if LethalGrenades.Value > 0 then
4984 LethalGrenades.Value = LethalGrenades.Value - 1
4985
4986 updateLethals()
4987
4988 ThrowingGrenade = true
4989 ThrowGrenade(1)
4990 ThrowingGrenade = false
4991 end
4992 end
4993 end
4994
4995 if Key == S.Keys.tacticalGrenade and S.Throwables then
4996 if (not Knifing) and (not Running) and (not Aimed) and (not Aiming) and (not ThrowingGrenade) then
4997 if TacticalGrenades.Value > 0 then
4998 TacticalGrenades.Value = TacticalGrenades.Value - 1
4999
5000 updateTacticals()
5001
5002 ThrowingGrenade = true
5003 ThrowGrenade(2)
5004 ThrowingGrenade = false
5005 end
5006 end
5007 end]]
5008
5009 if Key == S.Keys.Sprint then
5010 runKeyPressed = true
5011 if runReady then
5012 if (not Idling) and Walking and (not Running) and (not Knifing) and (not ThrowingGrenade) and (not (Aimed and S.guiScope and S.Keys.Sprint == S.Keys.scopeSteady)) then
5013 monitorStamina()
5014 end
5015 end
5016 end
5017
5018 if Key == S.Keys.scopeSteady then
5019 steadyKeyPressed = true
5020 if Aimed and (not Aiming) then
5021 takingBreath = false
5022 steadyCamera()
5023 end
5024 end
5025
5026 for _, PTable in pairs(Plugins.KeyDown) do
5027 if Key == string.lower(PTable.Key) then
5028 spawn(function()
5029 PTable.Plugin()
5030 end)
5031 end
5032 end
5033end
5034
5035function keyUp(K)
5036 local Key = string.lower(K)
5037
5038 if Key == S.Keys.ADS then
5039 if S.aimSettings.holdToADS then
5040 if (not AimingOut) and Aimed then
5041 AimingOut = true
5042 unAimGun()
5043 AimingOut = false
5044 end
5045 end
5046 end
5047
5048 if Key == S.Keys.Sprint then
5049 runKeyPressed = false
5050 Running = false
5051 if (not chargingStamina) then
5052 rechargeStamina()
5053 end
5054 end
5055
5056 if Key == S.Keys.scopeSteady then
5057 steadyKeyPressed = false
5058 end
5059
5060 for _, PTable in pairs(Plugins.KeyUp) do
5061 if Key == string.lower(PTable.Key) then
5062 spawn(function()
5063 PTable.Plugin()
5064 end)
5065 end
5066 end
5067end
5068
5069--------------------[ END FUNCTIONS ]-------------------------------------------------
5070
5071--------------------------------------------------------------------------------------
5072--------------------[ PRE-CONNECTIONS ]-----------------------------------------------
5073--------------------------------------------------------------------------------------
5074
5075local function updateAnimVars()
5076 wait()
5077 Forward = (UIS:IsKeyDown("W") or UIS:IsKeyDown("Up"))
5078 Backward = (UIS:IsKeyDown("S") or UIS:IsKeyDown("Down"))
5079 local Right = UIS:IsKeyDown("D")
5080 local Left = UIS:IsKeyDown("A")
5081
5082 local walkingForward = (Forward and (not Backward))
5083 local walkingBackward = ((not Forward) and Backward)
5084 local walkingRight = (Right and (not Left))
5085 local walkingLeft = ((not Right) and Left)
5086
5087 if (Forward or Backward or Right or Left) then
5088 Walking, Idling = true, false
5089 if (not Running) and (not Aimed) then
5090 spreadMotion = "Moving"
5091 baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion]
5092 end
5093 elseif (not (Forward and Backward and Right and Left)) then
5094 Walking, Idling = false, true
5095 if (not Aimed) then
5096 spreadMotion = "Idling"
5097 baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion]
5098 end
5099 end
5100
5101 local newArmTilt = (
5102 ((walkingForward or walkingBackward) and walkingRight) and 2.5 or
5103 ((walkingForward or walkingBackward) and walkingLeft) and -2.5 or
5104 ((not (walkingForward and walkingBackward)) and walkingRight) and 5 or
5105 ((not (walkingForward and walkingBackward)) and walkingLeft) and -5 or 0
5106 )
5107 local newMoveAng = (
5108 (walkingForward and (not (walkingRight or walkingLeft))) and 0 or
5109 (walkingForward and walkingRight) and RAD(-45) or
5110 ((not (walkingForward or walkingBackward)) and walkingRight) and RAD(-90) or
5111 (walkingBackward and walkingRight) and RAD(-135) or
5112 (walkingBackward and (not (walkingRight or walkingLeft))) and (moveAng < 0 and RAD(-180) or RAD(180)) or
5113 (walkingBackward and walkingLeft) and RAD(135) or
5114 ((not (walkingForward or walkingBackward)) and walkingLeft) and RAD(90) or
5115 (walkingForward and walkingLeft) and RAD(45) or 0
5116 )
5117
5118 local newAnimCode = math.random(-1e9, 1e9)
5119 animCode = newAnimCode
5120 local startTilt = armTilt
5121 local startAng = (ABS(moveAng) == RAD(180)) and (newMoveAng > 0 and RAD(180) or RAD(-180)) or moveAng
5122 local Increment = (startTilt == newArmTilt and 1.5 / 0.7 or 1.5 / (0.35 * ABS(startTilt - newArmTilt) / 5))
5123 local X = 0
5124 while true do
5125 RS.RenderStepped:wait()
5126 local newX = X + Increment
5127 X = (newX > 90 and 90 or newX)
5128 if animCode ~= newAnimCode then break end
5129 armTilt = numLerp(startTilt, newArmTilt, Sine(X))
5130 moveAng = numLerp(startAng, newMoveAng, Sine(X))
5131 if X == 90 then break end
5132 end
5133end
5134
5135M2.KeyDown:connect(updateAnimVars)
5136M2.KeyUp:connect(updateAnimVars)
5137updateAnimVars()
5138
5139--------------------------------------------------------------------------------------
5140--------------------[ TOOL SELECTION AND DESELECTION ]--------------------------------
5141--------------------------------------------------------------------------------------
5142
5143function onEquipped()
5144 wait()
5145 if Humanoid.Health ~= 0 and (not Selected) and Gun.Parent == Char then
5146 Selected = true
5147 breakReload = false
5148 equipAnimPlaying = true
5149
5150 math.randomseed(tick()) --This sets a new seed for the random function each time you select the gun
5151
5152 --------------------[ FAILSAFE RESETING ]-------------------------------------
5153
5154 for _, GM in pairs(ignoreModel:GetChildren()) do
5155 if GM.Name == "gunIgnore_"..Player.Name then
5156 GM:Destroy()
5157 end
5158 end
5159
5160 for _, c in pairs(Connections) do
5161 c:disconnect()
5162 end
5163
5164 Connections = {}
5165
5166 --------------------[ REMOTE GUN SETUP ]--------------------------------------
5167
5168 --[[local Vars = {
5169 ignoreModel = ignoreModel;
5170 Humanoid = Humanoid;
5171 Shoulders = Shoulders;
5172 Torso = Torso;
5173 Head = Head;
5174 armC0 = armC0;
5175 leftArmC1 = S.equipSettings.leftArmC1;
5176 rightArmC1 = S.equipSettings.rightArmC1;
5177 LArm = LArm;
5178 RArm = RArm;
5179 gunParts = gunParts;
5180 Handle = Handle;
5181 }
5182 gunIgnore, playerFolder, headWeld, headWeld2, animWeld, ABWeld, LWeld, RWeld, LWeld2, RWeld2, LLegWeld, RLegWeld, gunParts2 = gunSetup:InvokeServer(Vars)]]
5183
5184 --------------------[ CREATING IGNORE MODELS ]--------------------------------
5185
5186 gunIgnore = Instance.new("Model")
5187 gunIgnore.Name = "gunIgnore_"..Player.Name
5188 gunIgnore.Parent = ignoreModel
5189
5190 --------------------[ MODIFYING THE PLAYER ]----------------------------------
5191
5192 Player.CameraMode = Enum.CameraMode.LockFirstPerson
5193 Cam.CameraType = Enum.CameraType.Scriptable
5194 Cam.FieldOfView = 80
5195 UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
5196 UIS.MouseIconEnabled = false
5197
5198 local initialX, initialY = getYawPitch(Cam.CoordinateFrame)
5199 camAng = -VEC2(initialX, initialY)
5200
5201 mainGUI.Parent = Player.PlayerGui
5202
5203 setUpGUI()
5204 updateHealth()
5205
5206 if S.selectFire then
5207 local currentMode = Modes[((rawFireMode - 1) % numModes) + 1]
5208 if currentMode == "AUTO" then
5209 fireFunction = autoFire
5210 elseif currentMode == "BURST" then
5211 fireFunction = burstFire
5212 elseif currentMode == "SEMI" then
5213 fireFunction = semiFire
5214 else
5215 fireFunction = nil
5216 end
5217 else
5218 if S.gunType.Semi then
5219 fireFunction = semiFire
5220 elseif S.gunType.Auto then
5221 fireFunction = autoFire
5222 elseif S.gunType.Burst then
5223 fireFunction = burstFire
5224 else
5225 fireFunction = nil
5226 end
5227 end
5228
5229 changePlayerTrans(Char, 1)
5230
5231 Humanoid.AutoRotate = false
5232
5233 Shoulders.Right.Part1 = nil
5234 Shoulders.Left.Part1 = nil
5235
5236 playerFolder = Instance.new("Model")
5237 playerFolder.Name = "playerFolder"
5238 playerFolder.Parent = gunIgnore
5239
5240 local headBase = Instance.new("Part")
5241 headBase.Transparency = 1
5242 headBase.Name = "headBase"
5243 headBase.CanCollide = false
5244 headBase.FormFactor = Enum.FormFactor.Custom
5245 headBase.Size = V3(0.2, 0.2, 0.2)
5246 headBase.BottomSurface = Enum.SurfaceType.Smooth
5247 headBase.TopSurface = Enum.SurfaceType.Smooth
5248 headBase.Parent = playerFolder
5249
5250 headWeld = Instance.new("Weld")
5251 headWeld.Part0 = Torso
5252 headWeld.Part1 = headBase
5253 headWeld.C0 = CF(0, 1.5, 0)
5254 headWeld.Parent = Torso
5255
5256 headWeld2 = Instance.new("Weld")
5257 headWeld2.Part0 = headBase
5258 headWeld2.Part1 = Head
5259 headWeld2.Parent = headBase
5260
5261 neckClone = Neck:Clone()
5262
5263 --[[local stanceBase = Instance.new("Part")
5264 stanceBase.Transparency = 1
5265 stanceBase.Name = "stanceBase"
5266 stanceBase.CanCollide = false
5267 stanceBase.FormFactor = Enum.FormFactor.Custom
5268 stanceBase.Size = V3(0.2, 0.2, 0.2)
5269 stanceBase.BottomSurface = Enum.SurfaceType.Smooth
5270 stanceBase.TopSurface = Enum.SurfaceType.Smooth
5271 stanceBase.Parent = playerFolder
5272
5273 stanceWeld = Instance.new("Weld")
5274 stanceWeld.Part0 = stanceBase
5275 stanceWeld.Part1 = Torso
5276 stanceWeld.Parent = stanceBase]]
5277
5278 local animBase = Instance.new("Part")
5279 animBase.Transparency = 1
5280 animBase.Name = "animBase"
5281 animBase.CanCollide = false
5282 animBase.FormFactor = Enum.FormFactor.Custom
5283 animBase.Size = V3(0.2, 0.2, 0.2)
5284 animBase.BottomSurface = Enum.SurfaceType.Smooth
5285 animBase.TopSurface = Enum.SurfaceType.Smooth
5286 animBase.Parent = playerFolder
5287
5288 animWeld = Instance.new("Weld")
5289 animWeld.Part0 = animBase
5290 animWeld.Part1 = headBase
5291 animWeld.Parent = animBase
5292
5293 local ArmBase = Instance.new("Part")
5294 ArmBase.Transparency = 1
5295 ArmBase.Name = "ArmBase"
5296 ArmBase.CanCollide = false
5297 ArmBase.FormFactor = Enum.FormFactor.Custom
5298 ArmBase.Size = V3(0.2, 0.2, 0.2)
5299 ArmBase.BottomSurface = Enum.SurfaceType.Smooth
5300 ArmBase.TopSurface = Enum.SurfaceType.Smooth
5301 ArmBase.Parent = playerFolder
5302
5303 ABWeld = Instance.new("Weld")
5304 ABWeld.Part0 = ArmBase
5305 ABWeld.Part1 = animBase
5306 ABWeld.Parent = ArmBase
5307
5308 local LArmBase = Instance.new("Part")
5309 LArmBase.Transparency = 1
5310 LArmBase.Name = "LArmBase"
5311 LArmBase.CanCollide = false
5312 LArmBase.FormFactor = Enum.FormFactor.Custom
5313 LArmBase.Size = V3(0.2, 0.2, 0.2)
5314 LArmBase.BottomSurface = Enum.SurfaceType.Smooth
5315 LArmBase.TopSurface = Enum.SurfaceType.Smooth
5316 LArmBase.Parent = playerFolder
5317
5318 local RArmBase = Instance.new("Part")
5319 RArmBase.Transparency = 1
5320 RArmBase.Name = "RArmBase"
5321 RArmBase.CanCollide = false
5322 RArmBase.FormFactor = Enum.FormFactor.Custom
5323 RArmBase.Size = V3(0.2, 0.2, 0.2)
5324 RArmBase.BottomSurface = Enum.SurfaceType.Smooth
5325 RArmBase.TopSurface = Enum.SurfaceType.Smooth
5326 RArmBase.Parent = playerFolder
5327
5328 LWeld = Instance.new("Weld")
5329 LWeld.Name = "LWeld"
5330 LWeld.Part0 = ArmBase
5331 LWeld.Part1 = LArmBase
5332 LWeld.C0 = armC0[1]
5333 LWeld.C1 = S.equipSettings.leftArmC1
5334 LWeld.Parent = ArmBase
5335
5336 RWeld = Instance.new("Weld")
5337 RWeld.Name = "RWeld"
5338 RWeld.Part0 = ArmBase
5339 RWeld.Part1 = RArmBase
5340 RWeld.C0 = armC0[2]
5341 RWeld.C1 = S.equipSettings.rightArmC1
5342 RWeld.Parent = ArmBase
5343
5344 LWeld2 = Instance.new("Weld")
5345 LWeld2.Name = "LWeld"
5346 LWeld2.Part0 = LArmBase
5347 LWeld2.Part1 = LArm
5348 LWeld2.Parent = LArmBase
5349
5350 RWeld2 = Instance.new("Weld")
5351 RWeld2.Name = "RWeld"
5352 RWeld2.Part0 = RArmBase
5353 RWeld2.Part1 = RArm
5354 RWeld2.Parent = RArmBase
5355
5356 LLegWeld = Instance.new("Weld")
5357 LLegWeld.Name = "LLegWeld"
5358 LLegWeld.Part0 = Torso
5359 LLegWeld.Part1 = nil
5360 LLegWeld.C0 = CF(-0.5, -2, 0)
5361 LLegWeld.Parent = Torso
5362
5363 RLegWeld = Instance.new("Weld")
5364 RLegWeld.Name = "RLegWeld"
5365 RLegWeld.Part0 = Torso
5366 RLegWeld.Part1 = nil
5367 RLegWeld.C0 = CF(0.5, -2, 0)
5368 RLegWeld.Parent = Torso
5369
5370 if S.playerArms then
5371 armModel = Instance.new("Model", workspace.FilteringEnabled and playerFolder or Cam)
5372
5373 fakeLArm = LArm:Clone()
5374 fakeLArm.Parent = armModel
5375 fakeLArm.Transparency = S.fakeArmSettings.Transparency
5376 fakeLArm.CanCollide = false
5377 fakeLArm.Size = S.fakeArmSettings.armSize
5378 fakeLArm:BreakJoints()
5379
5380 --LArm.Transparency = 1
5381
5382 local fakeLWeld = Instance.new("Weld")
5383 fakeLWeld.Part0 = fakeLArm
5384 fakeLWeld.Part1 = LArm
5385 fakeLWeld.Parent = fakeLArm
5386
5387 fakeRArm = RArm:Clone()
5388 fakeRArm.Parent = armModel
5389 fakeRArm.Transparency = S.fakeArmSettings.Transparency
5390 fakeRArm.CanCollide = false
5391 fakeRArm.Size = S.fakeArmSettings.armSize
5392 fakeRArm:BreakJoints()
5393
5394 --RArm.Transparency = 1
5395
5396 local fakeRWeld = Instance.new("Weld")
5397 fakeRWeld.Part0 = fakeRArm
5398 fakeRWeld.Part1 = RArm
5399 fakeRWeld.Parent = fakeRArm
5400
5401 Instance.new("Humanoid", armModel)
5402
5403 if S.fakeArmSettings.characterMeshes then
5404 for _,Obj in pairs(Char:GetChildren()) do
5405 if Obj:IsA("CharacterMesh") then
5406 Obj:Clone().Parent = armModel
5407 end
5408 end
5409 end
5410 for _,Obj in pairs(Char:GetChildren()) do
5411 if Obj:IsA("Shirt") then
5412 Obj:Clone().Parent = armModel
5413 end
5414 end
5415 else
5416 armTable = createArms()
5417 if workspace.FilteringEnabled then
5418 armTable[1].Model.Parent = playerFolder
5419 armTable[2].Model.Parent = playerFolder
5420 else
5421 armTable[1].Model.Parent = Cam--playerFolder
5422 armTable[2].Model.Parent = Cam--playerFolder
5423 end
5424
5425 fakeLArm = armTable[1].armPart
5426
5427 --LArm.Transparency = 1
5428
5429 local fakeLWeld = Instance.new("Weld")
5430 fakeLWeld.Part0 = fakeLArm
5431 fakeLWeld.Part1 = LArm
5432 fakeLWeld.Parent = fakeLArm
5433
5434 fakeRArm = armTable[2].armPart
5435
5436 --RArm.Transparency = 1
5437
5438 local fakeRWeld = Instance.new("Weld")
5439 fakeRWeld.Part0 = fakeRArm
5440 fakeRWeld.Part1 = RArm
5441 fakeRWeld.Parent = fakeRArm
5442 end
5443
5444 --------------------[ MODIFYING THE GUN ]-------------------------------------
5445
5446 for _, Tab in pairs(gunParts) do
5447 local Weld = Instance.new("Weld")
5448 Weld.Name = "MainWeld"
5449 Weld.Part0 = Handle
5450 Weld.Part1 = Tab.Obj
5451 Weld.C0 = Tab.Obj.weldCF.Value
5452 Weld.Parent = Handle
5453 Tab.Weld = Weld
5454 end
5455
5456 Grip = RArm:WaitForChild("RightGrip")
5457 HUD:WaitForChild("Co"):Destroy()
5458
5459 local handleCF = Torso.CFrame * CF(0, 0.5, 0) * armC0[2] * S.aimedC1.rightArm:inverse() * Grip.C0
5460 local handleOffset = AimPart.CFrame:toObjectSpace(Handle.CFrame)
5461 aimedGripCF = ((Torso.CFrame * CF(headOffset.X, headOffset.Y, 0)) * handleOffset):toObjectSpace(handleCF)
5462
5463 Grip.C1 = S.equipSettings.GripC1
5464
5465 --------------------[ RUNNING PLUGINS ]---------------------------------------
5466
5467 for _, Plugin in pairs(Plugins.OnEquipped) do
5468 spawn(function()
5469 Plugin()
5470 end)
5471 end
5472
5473 --------------------[ GETTING PLAYER MASS ]-----------------------------------
5474
5475 local connectedParts = HRP:GetConnectedParts(true)
5476 for _, v in pairs(connectedParts) do
5477 if v:IsA("BasePart") then
5478 playerMass = playerMass + v:GetMass()
5479 end
5480 end
5481
5482 --------------------[ CONNECTIONS ]-------------------------------------------
5483
5484 INSERT(Connections, Humanoid.Died:connect(function()
5485 onUnequipped(true)
5486 end))
5487
5488 INSERT(Connections, Humanoid.Jumping:connect(function()
5489 if Stance ~= 0 then
5490 Stand()
5491 end
5492 end))
5493
5494 INSERT(Connections, Humanoid.StateChanged:connect(onHumanoidStateChanged))
5495
5496 INSERT(Connections, Humanoid.HealthChanged:connect(updateHealth))
5497
5498 INSERT(Connections, M2.Button1Down:connect(onMB1Down))
5499
5500 INSERT(Connections, M2.Button1Up:connect(onMB1Up))
5501
5502 INSERT(Connections, M2.Button2Down:connect(onMB2Down))
5503
5504 INSERT(Connections, M2.Button2Up:connect(onMB2Up))
5505
5506 INSERT(Connections, M2.KeyDown:connect(keyDown))
5507
5508 INSERT(Connections, M2.KeyUp:connect(keyUp))
5509
5510 if S.sensitivitySettings.scrollToChange then
5511 INSERT(Connections, M2.WheelForward:connect(onScrollUp))
5512 INSERT(Connections, M2.WheelBackward:connect(onScrollDown))
5513 end
5514
5515 if S.AutoKnife then
5516 INSERT(Connections, RS.Stepped:connect(function()
5517 local H, P = AdvRayCast(Head.CFrame.p, Head.CFrame.lookVector, S.AutoKnifeDist, nil)
5518 if H then
5519 local HitHuman = findFirstClass(H.Parent, "Humanoid")
5520 if HitHuman and isEnemy(HitHuman) and HitHuman.Health ~= 0 then
5521 Knife()
5522 end
5523 end
5524 end))
5525 end
5526
5527 INSERT(Connections, UIS.InputChanged:connect(function(inputObj)
5528 if inputObj.UserInputType == Enum.UserInputType.MouseMovement then
5529 local rawCamAng = camAng - (VEC2(RAD(inputObj.Delta.x), RAD(inputObj.Delta.y)) * mouseSensitivity * 0.25)
5530 camAng = VEC2(rawCamAng.x, (rawCamAng.y > RAD(80) and RAD(80) or rawCamAng.y < RAD(-80) and RAD(-80) or rawCamAng.y))
5531
5532 desiredXOffset = math.min(math.max(inputObj.Delta.x, -S.momentumSettings.maxInput), S.momentumSettings.maxInput)
5533 desiredYOffset = math.min(math.max(inputObj.Delta.y, -S.momentumSettings.maxInput), S.momentumSettings.maxInput)
5534 end
5535 end))
5536
5537 INSERT(Connections, M2.Idle:connect(function(inputObj)
5538 desiredXOffset = 0
5539 desiredYOffset = 0
5540 end))
5541
5542 INSERT(Connections, RS.Stepped:connect(function()
5543 if tick() - lastBeat > (Humanoid.Health / 75) then
5544 lastBeat = tick()
5545 HUD.Health.Tray.Beat:TweenPosition(
5546 UDim2.new(0, -21, 0, 0),
5547 Enum.EasingDirection.Out,
5548 Enum.EasingStyle.Linear,
5549 0.7 - ((100 - Humanoid.Health) / 400),
5550 false,
5551 function()
5552 HUD.Health.Tray.Beat.Position = UDim2.new(1, 0, 0, 0)
5553 end
5554 )
5555 end
5556 end))
5557
5558 INSERT(Connections, RS.RenderStepped:connect(function()
5559 --Main animation
5560 local animC0, animC1 = getAnimCF()
5561 animWeld.C0 = animC0
5562 animWeld.C1 = animC1
5563
5564 --Camera updating
5565 renderCamera()
5566 end))
5567
5568 --------------------[ ANIMATE GUN ]-------------------------------------------
5569
5570 tweenJoint(LWeld, nil, S.unAimedC1.leftArm, Sine, S.equipSettings.Time)
5571 tweenJoint(RWeld, nil, S.unAimedC1.rightArm, Sine, S.equipSettings.Time)
5572 tweenJoint(Grip, nil, S.unAimedC1.Grip, Sine, S.equipSettings.Time)
5573 spawn(function()
5574 local T = tick()
5575 while true do
5576 if tick() - T > S.equipSettings.Time then break end
5577 if (not Selected) then break end
5578 wait()
5579 end
5580 equipAnimPlaying = false
5581 end)
5582
5583 Animate()
5584 end
5585end
5586
5587function onUnequipped(deleteTool)
5588 if Selected then
5589 Selected = false
5590
5591 breakReload = true
5592
5593 --------------------[ RUNNING PLUGINS ]---------------------------------------
5594
5595 for _, Plugin in pairs(Plugins.OnUnEquipped) do
5596 spawn(function()
5597 Plugin()
5598 end)
5599 end
5600
5601 --------------------[ MODIFYING THE PLAYER ]----------------------------------
5602
5603 Cam.FieldOfView = 70
5604 Cam.CameraType = Enum.CameraType.Custom
5605
5606 UIS.MouseBehavior = Enum.MouseBehavior.Default
5607 UIS.MouseIconEnabled = true
5608
5609 Player.CameraMode = Enum.CameraMode.Classic
5610
5611 if armTable then
5612 armTable[1].Model:Destroy()
5613 armTable[2].Model:Destroy()
5614 elseif armModel then
5615 armModel:Destroy()
5616 end
5617
5618 LLegWeld:Destroy()
5619 RLegWeld:Destroy()
5620
5621 changePlayerTrans(Char, 0)
5622
5623 mainGUI.Parent = script
5624
5625 Shoulders.Right.Part1 = RArm
5626 Shoulders.Left.Part1 = LArm
5627
5628 neckClone.Parent = Torso
5629 headWeld:Destroy()
5630
5631 Humanoid.WalkSpeed = 16
5632 Humanoid.AutoRotate = true
5633
5634 --------------------[ RESETING THE TOOL ]-------------------------------------
5635
5636 gunIgnore:Destroy()
5637
5638 mouseSensitivity = S.sensitivitySettings.Default
5639
5640 MB1Down = false
5641
5642 playerMass = 0
5643
5644 Aimed = false
5645
5646 camOffsets = {
5647 guiScope = {
5648 Rot = V3();
5649 };
5650 Reload = {
5651 Rot = V3();
5652 Code = nil;
5653 };
5654 Recoil = {
5655 Rot = V3();
5656 Code = nil;
5657 };
5658 }
5659
5660 recoilAnim = {
5661 Pos = V3();
5662 Rot = V3();
5663 Code = nil;
5664 }
5665
5666 --Setting the aim variables to unaimed
5667 spreadZoom = "unAimed"
5668 scopeMain.Visible = false
5669 scopeSteady.Visible = false
5670 aimAlpha = 0
5671 aimHeadOffset = 0
5672 jumpAnimMultiplier = 1
5673 translationDivisor = 7
5674 rotationMultiplier = S.momentumSettings.Amplitude.unAimed
5675 armTiltMultiplier = 1
5676 Scope.BackgroundTransparency = 1
5677 if S.guiScope then
5678 spawn(function()
5679 for _, Obj in pairs(Gun:GetChildren()) do
5680 if Obj:IsA("BasePart") then
5681 Obj.LocalTransparencyModifier = 0
5682 end
5683 end
5684 end)
5685 end
5686
5687 onGround = true
5688
5689 for _, Tab in pairs(gunParts) do
5690 Tab.Weld:Destroy()
5691 Tab.Weld = nil
5692 end
5693
5694 for _,c in pairs(Connections) do
5695 c:disconnect()
5696 end
5697
5698 Connections = {}
5699
5700 if deleteTool then
5701 Cam:ClearAllChildren()
5702 Gun:Destroy()
5703 end
5704
5705 wait() --This is here in case you dolphin dived and deselected the tool instantly
5706
5707 if S.stanceSettings.standOnDeselect and Stance ~= 0 then
5708 crawlCamRot = 0
5709 isCrawling = false
5710 stanceSway = 1
5711 spreadStance = "Stand"
5712 Stand(true)
5713 end
5714 baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion]
5715 end
5716end
5717
5718Gun.Equipped:connect(onEquipped)
5719Gun.Unequipped:connect(function() onUnequipped(false) end)
5720
5721--------------------------------------------------------------------------------------
5722--------------------[ END PROGRAM ]---------------------------------------------------
5723--------------------------------------------------------------------------------------
5724end))