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