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