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