View difference between Paste ID: QZgpg6f5 and scJ2B7yn
SHOW: | | - or go back to the newest paste.
1
--[[
2
Flare Gun
3
A red flare gun.
4
--]]
5
6
7
if script == nil then return end
8
9
10
ModelName = "Flare Gun"
11
AmmoType = "Flare Grenades"
12
MagazineCapacity = 1
13
MagazineCapacityAdd = 0
14
Color = Color3.new(1, 0, 0)
15-
Player = script:FindFirstChild("Player") ~= nil and script.Player.Value or game:GetService("Players"):FindFirstChild("DarkShadow6Alt")
15+
Player = script:FindFirstChild("Player") ~= nil and script.Player.Value or game:GetService("Players"):FindFirstChild("DragonBxllinGamver")
16
Selected = false
17
Connected = false
18
Button1Down = false
19
CanUse = true
20
FirstPerson = game:GetService("InsertService"):LoadAsset(60568552)["FirstPerson"].Value
21
MouseAim = game:GetService("InsertService"):LoadAsset(61527949)["MouseAim"].Value
22
AmmoCounter = game:GetService("InsertService"):LoadAsset(66610412)["AmmoCounter"].Value
23
24
25
function CheckPlayer()
26
	if Player.Character == nil then return false end
27
	if Player.Character:FindFirstChild("Torso") == nil or Player.Character:FindFirstChild("Right Arm") == nil or Player.Character:FindFirstChild("Left Arm") == nil or Player.Character:FindFirstChild("Humanoid") == nil then return false end
28
	if Player.Character.Humanoid.Health <= 0 then return false end
29
	return true
30
end
31
32
33
loadstring(game:GetService("InsertService"):LoadAsset(65363615)["tagHumanoid"].Value)()
34
35
36
loadstring(game:GetService("InsertService"):LoadAsset(63178291)["CameraPunch"].Value)()
37
38
39
loadstring(game:GetService("InsertService"):LoadAsset(62991657)["PacketFunctions"].Value)()
40
41
42
function CreateParts(Parent, Format)
43
	if Parent == nil then return end
44
	local Parts = Instance.new("Model")
45
	Parts.Name = ModelName
46
	if Format == 1 then
47
		Parts.Name = Parts.Name.. " (Holstered)"
48
	end
49
	Parts.Parent = Parent
50
51
	local MasterPart = Instance.new("Part")
52
	MasterPart.Name = "Handle"
53
	MasterPart.BrickColor = BrickColor.new(Color)
54
	MasterPart.TopSurface = 0
55
	MasterPart.BottomSurface = 0
56
	MasterPart.FormFactor = "Custom"
57
	MasterPart.Size = Vector3.new(0.3, 0.4, 0.35)
58
	MasterPart.Parent = Parts
59
	local Weld = Instance.new("Weld")
60
	Weld.Part0 = MasterPart
61
	if Format == 1 then
62
		Weld.Part1 = Player.Character:FindFirstChild("Right Arm")
63
		Weld.C1 = CFrame.new(0.6, 0.4, 0)
64
	elseif Format == 2 then
65
		Weld.Part1 = Player.Character:FindFirstChild("Right Arm")
66
		Weld.C1 = CFrame.new(0, -1.1, -0.3)
67
	end
68
	Weld.Parent = Weld.Part0
69
70
	local Part = Instance.new("Part")
71
	Part.Name = "Trigger 1"
72
	Part.BrickColor = BrickColor.new(Color)
73
	Part.TopSurface = 0
74
	Part.BottomSurface = 0
75
	Part.FormFactor = "Custom"
76
	Part.Size = Vector3.new(0.2, 0.2, 0.2)
77
	Part.Parent = Parts
78
	local Weld = Instance.new("Weld")
79
	Weld.Part0 = Part
80
	Weld.Part1 = MasterPart
81
	Weld.C0 = CFrame.new(0, 0.3, -0.075)
82
	Weld.Parent = Weld.Part0
83
	local Mesh = Instance.new("SpecialMesh", Part)
84
	Mesh.MeshType = "Brick"
85
	Mesh.Scale = Vector3.new(0.05 / 0.2, 0.01 / 0.2, 0.1 / 0.2)
86
87
	local Part = Instance.new("Part")
88
	Part.Name = "Trigger Guard"
89
	Part.BrickColor = BrickColor.new(Color)
90
	Part.TopSurface = 0
91
	Part.BottomSurface = 0
92
	Part.FormFactor = "Custom"
93
	Part.Size = Vector3.new(0.2, 0.2, 0.2)
94
	Part.Parent = Parts
95
	local Weld = Instance.new("Weld")
96
	Weld.Part0 = Part
97
	Weld.Part1 = MasterPart
98
	Weld.C0 = CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
99
	Weld.C1 = CFrame.new(0, -0.3, 0.1)
100
	Weld.Parent = Weld.Part0
101
	local Mesh = Instance.new("SpecialMesh", Part)
102
	Mesh.MeshType = "FileMesh"
103
	Mesh.MeshId = "http://www.roblox.com/Asset/?id=3270017"
104
	Mesh.Scale = Vector3.new(0.25, 0.3, 0.4)
105
106
	local Part = Instance.new("Part")
107
	Part.Name = "Grip 1"
108
	Part.BrickColor = BrickColor.new(Color)
109
	Part.TopSurface = 0
110
	Part.BottomSurface = 0
111
	Part.FormFactor = "Custom"
112
	Part.Size = Vector3.new(0.29, 0.35, 0.7)
113
	Part.Locked = true
114
	Part.Parent = Parts
115
	local Weld = Instance.new("Weld")
116
	Weld.Part0 = Part
117
	Weld.Part1 = MasterPart
118
	Weld.C0 = CFrame.new(0, 0, -0.4) * CFrame.fromEulerAnglesXYZ(math.rad(20), 0, 0)
119
	Weld.Parent = Weld.Part0
120
121
	local Part = Instance.new("Part")
122
	Part.Name = "Grip 2"
123
	Part.BrickColor = BrickColor.new("White")
124
	Part.TopSurface = 0
125
	Part.BottomSurface = 0
126
	Part.FormFactor = "Custom"
127
	Part.Size = Vector3.new(0.31, 0.25, 0.6)
128
	Part.Locked = true
129
	Part.Parent = Parts
130
	local Weld = Instance.new("Weld")
131
	Weld.Part0 = Part
132
	Weld.Part1 = MasterPart
133
	Weld.C0 = CFrame.new(0, 0, -0.4) * CFrame.fromEulerAnglesXYZ(math.rad(20), 0, 0)
134
	Weld.Parent = Weld.Part0
135
136
	local Part = Instance.new("WedgePart")
137
	Part.Name = "Handle Body 1"
138
	Part.BrickColor = BrickColor.new(Color)
139
	Part.TopSurface = 0
140
	Part.BottomSurface = 0
141
	Part.FormFactor = "Custom"
142
	Part.Size = Vector3.new(0.3, 0.4, 0.2)
143
	Part.Parent = Parts
144
	local Weld = Instance.new("Weld")
145
	Weld.Part0 = Part
146
	Weld.Part1 = MasterPart
147
	Weld.C0 = CFrame.new(0, 0, 0.25)
148
	Weld.Parent = Weld.Part0
149
	local Mesh = Instance.new("SpecialMesh", Part)
150
	Mesh.MeshType = "Wedge"
151
	Mesh.Scale = Vector3.new(1, 1, 0.15 / 0.2)
152
153
	local Part = Instance.new("Part")
154
	Part.Name = "Handle Body 2"
155
	Part.BrickColor = BrickColor.new(Color)
156
	Part.TopSurface = 0
157
	Part.BottomSurface = 0
158
	Part.FormFactor = "Custom"
159
	Part.Size = Vector3.new(0.3, 0.2, 0.35)
160
	Part.Locked = true
161
	Part.Parent = Parts
162
	local Weld = Instance.new("Weld")
163
	Weld.Part0 = Part
164
	Weld.Part1 = MasterPart
165
	Weld.C0 = CFrame.new(0, 0.225, 0.15)
166
	Weld.Parent = Weld.Part0
167
	local Mesh = Instance.new("SpecialMesh", Part)
168
	Mesh.MeshType = "Brick"
169
	Mesh.Scale = Vector3.new(1, 0.05 / 0.2, 1)
170
171
	local Part = Instance.new("Part")
172
	Part.Name = "Handle Body 3"
173
	Part.BrickColor = BrickColor.new(Color)
174
	Part.TopSurface = 0
175
	Part.BottomSurface = 0
176
	Part.FormFactor = "Custom"
177
	Part.Size = Vector3.new(0.3, 1, 0.2)
178
	Part.Parent = Parts
179
	local Weld = Instance.new("Weld")
180
	Weld.Part0 = Part
181
	Weld.Part1 = MasterPart
182
	Weld.C0 = CFrame.new(0, 0.75, 0.075)
183
	Weld.Parent = Weld.Part0
184
185
	local Part = Instance.new("Part")
186
	Part.Name = "Barrel"
187
	Part.BrickColor = BrickColor.new(Color)
188
	Part.TopSurface = 0
189
	Part.BottomSurface = 0
190
	Part.FormFactor = "Custom"
191
	Part.Size = Vector3.new(0.4, 1, 0.4)
192
	Part.Parent = Parts
193
	local Weld = Instance.new("Weld")
194
	Weld.Part0 = Part
195
	Weld.Part1 = MasterPart
196
	Weld.C0 = CFrame.new(0, 0.75, 0.2)
197
	Weld.Parent = Weld.Part0
198
	Instance.new("CylinderMesh", Part)
199
200
	local Part = Instance.new("Part")
201
	Part.Name = "Barrel Hole"
202
	Part.BrickColor = BrickColor.new("Really black")
203
	Part.TopSurface = 0
204
	Part.BottomSurface = 0
205
	Part.FormFactor = "Custom"
206
	Part.Size = Vector3.new(0.3, 0.2, 0.3)
207
	Part.Parent = Parts
208
	local Weld = Instance.new("Weld")
209
	Weld.Part0 = Part
210
	Weld.Part1 = MasterPart
211
	Weld.C0 = CFrame.new(0, 1.151, 0.2)
212
	Weld.Parent = Weld.Part0
213
	Instance.new("CylinderMesh", Part)
214
215
	local Part = Instance.new("Part")
216
	Part.Name = "Source"
217
	Part.TopSurface = 0
218
	Part.BottomSurface = 0
219
	Part.FormFactor = "Custom"
220
	Part.Size = Vector3.new(0.2, 0.2, 0.2)
221
	Part.Transparency = 1
222
	Part.Parent = Parts
223
	local Weld = Instance.new("Weld")
224
	Weld.Part0 = Part
225
	Weld.Part1 = MasterPart
226
	Weld.C0 = CFrame.new(0, 2, 0.2)
227
	Weld.Parent = Weld.Part0
228
	local Fire = Instance.new("Fire", Part)
229
	Fire.Enabled = false
230
	Fire.Size = 3
231
	Fire.Heat = -10
232
	Fire.Color = Color
233
	Fire.SecondaryColor = Color3.new(1, 1, 1)
234
235
	for _, Part in pairs(Parts:GetChildren()) do
236
		Part.Locked = true
237
		Part.CanCollide = false
238
	end
239
end
240
241
242
function RemoveParts(Parent, Format)
243
	if Format == 1 then
244
		pcall(function() Parent[ModelName.. " (Holstered)"]:Remove() end)
245
	elseif Format == 2 then
246
		pcall(function() Parent[ModelName]:Remove() end)
247
	end
248
end
249
250
251
function SetAngle(Joint, Angle, Character)
252
	if Character == nil then return false end
253
	local Joints = {
254
		Character.Torso:FindFirstChild("Right Shoulder 2"),
255
		Character.Torso:FindFirstChild("Left Shoulder 2"),
256
		Character.Torso:FindFirstChild("Right Hip 2"),
257
		Character.Torso:FindFirstChild("Left Hip 2")
258
	}
259
	if Joints[Joint] == nil then return false end
260
	if Joint == 1 or Joint == 3 then
261
		Joints[Joint].DesiredAngle = Angle
262
	end
263
	if Joint == 2 or Joint == 4 then
264
		Joints[Joint].DesiredAngle = -Angle
265
	end
266
end
267
268
269
function ForceAngle(Joint, Angle, Character)
270
	if Character == nil then return false end
271
	local Joints = {
272
		Character.Torso:FindFirstChild("Right Shoulder 2"),
273
		Character.Torso:FindFirstChild("Left Shoulder 2"),
274
		Character.Torso:FindFirstChild("Right Hip 2"),
275
		Character.Torso:FindFirstChild("Left Hip 2")
276
	}
277
	if Joints[Joint] == nil then return false end
278
	if Joint == 1 or Joint == 3 then
279
		Joints[Joint].DesiredAngle = Angle
280
		Joints[Joint].CurrentAngle = Angle
281
	end
282
	if Joint == 2 or Joint == 4 then
283
		Joints[Joint].DesiredAngle = -Angle
284
		Joints[Joint].CurrentAngle = -Angle
285
	end
286
end
287
288
289
function SetSpeed(Joint, Speed, Character)
290
	if Character == nil then return false end
291
	local Joints = {
292
		Character.Torso:FindFirstChild("Right Shoulder 2"),
293
		Character.Torso:FindFirstChild("Left Shoulder 2"),
294
		Character.Torso:FindFirstChild("Right Hip 2"),
295
		Character.Torso:FindFirstChild("Left Hip 2")
296
	}
297
	if Joints[Joint] == nil then return false end
298
	Joints[Joint].MaxVelocity = Speed
299
end
300
301
302
function DisableLimb(Limb, Character)
303
	if Character == nil then return false end
304
	if Character:FindFirstChild("Torso") == nil then return false end
305
	local Joints = {
306
		Character.Torso:FindFirstChild("Right Shoulder"),
307
		Character.Torso:FindFirstChild("Left Shoulder"),
308
		Character.Torso:FindFirstChild("Right Hip"),
309
		Character.Torso:FindFirstChild("Left Hip")
310
	}
311
	local Limbs = {
312
		Character:FindFirstChild("Right Arm"),
313
		Character:FindFirstChild("Left Arm"),
314
		Character:FindFirstChild("Right Leg"),
315
		Character:FindFirstChild("Left Leg")
316
	}
317
	if Joints[Limb] == nil then return false end
318
	if Limbs[Limb] == nil then return false end
319
	local Joint = Instance.new("Motor6D")
320
	Joint.Parent = Character.Torso
321
	Joint.Part0 = Character.Torso
322
	Joint.Part1 = Limbs[Limb]
323
	if Limb == 1 then
324
		Joint.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
325
		Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
326
		Joint.Name = "Right Shoulder 2"
327
	elseif Limb == 2 then
328
		Joint.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
329
		Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
330
		Joint.Name = "Left Shoulder 2"
331
	elseif Limb == 3 then
332
		Joint.C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
333
		Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
334
		Joint.Name = "Right Hip 2"
335
	elseif Limb == 4 then
336
		Joint.C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
337
		Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
338
		Joint.Name = "Left Hip 2"
339
	end
340
	Joint.MaxVelocity = Joints[Limb].MaxVelocity
341
	Joint.CurrentAngle = Joints[Limb].CurrentAngle
342
	Joint.DesiredAngle = Joints[Limb].DesiredAngle
343
	Joints[Limb]:Remove()
344
end
345
346
347
function ResetLimbCFrame(Limb, Character)
348
	if Character == nil then return false end
349
	if Character.Parent == nil then return false end
350
	if Character:FindFirstChild("Torso") == nil then return false end
351
	local Joints = {
352
		Character.Torso:FindFirstChild("Right Shoulder 2"),
353
		Character.Torso:FindFirstChild("Left Shoulder 2"),
354
		Character.Torso:FindFirstChild("Right Hip 2"),
355
		Character.Torso:FindFirstChild("Left Hip 2")
356
	}
357
	local Limbs = {
358
		Character:FindFirstChild("Right Arm"),
359
		Character:FindFirstChild("Left Arm"),
360
		Character:FindFirstChild("Right Leg"),
361
		Character:FindFirstChild("Left Leg")
362
	}
363
	if Joints[Limb] == nil then return false end
364
	if Limbs[Limb] == nil then return false end
365
	if Limb == 1 then
366
		Joints[Limb].C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
367
		Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
368
	elseif Limb == 2 then
369
		Joints[Limb].C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
370
		Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
371
	elseif Limb == 3 then
372
		Joints[Limb].C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
373
		Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
374
	elseif Limb == 4 then
375
		Joints[Limb].C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
376
		Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
377
	end
378
end
379
380
381
function EnableLimb(Limb, Character)
382
	if Character == nil then return false end
383
	if Character:FindFirstChild("Torso") == nil then return false end
384
	local Joints = {
385
		Character.Torso:FindFirstChild("Right Shoulder 2"),
386
		Character.Torso:FindFirstChild("Left Shoulder 2"),
387
		Character.Torso:FindFirstChild("Right Hip 2"),
388
		Character.Torso:FindFirstChild("Left Hip 2")
389
	}
390
	local Limbs = {
391
		Character:FindFirstChild("Right Arm"),
392
		Character:FindFirstChild("Left Arm"),
393
		Character:FindFirstChild("Right Leg"),
394
		Character:FindFirstChild("Left Leg")
395
	}
396
	if Joints[Limb] == nil then return false end
397
	if Limbs[Limb] == nil then return false end
398
	if Limb == 1 then
399
		Joints[Limb].Name = "Right Shoulder"
400
	elseif Limb == 2 then
401
		Joints[Limb].Name = "Left Shoulder"
402
	elseif Limb == 3 then
403
		Joints[Limb].Name = "Right Hip"
404
	elseif Limb == 4 then
405
		Joints[Limb].Name = "Left Hip"
406
	end
407
	Animate = Character:FindFirstChild("Animate")
408
	if Animate == nil then return false end
409
	Animate = Animate:Clone()
410
	Character.Animate:Remove()
411
	Animate.Parent = Character
412
end
413
414
415
function onButton1Down(Mouse)
416
	if Button1Down == true then return end
417
	Button1Down = true
418
	if CheckPlayer() == false then return end
419
	if CanUse == true then
420
		SoundToServer("Click", "http://www.roblox.com/Asset/?id=2697295", 15, 0.25, false, Player.Character[ModelName].Handle)
421
		if script.Magazine.Value <= 0 then
422
			return
423
		end
424
		CanUse = false
425
		SoundToServer("Fire", "http://www.roblox.com/Asset/?id=10209248", 1.5, 1, false, Player.Character[ModelName].Handle)
426
		script.Magazine.Value = script.Magazine.Value - 1
427
		pcall(function() Player.Character[ModelName].Source.Fire.Enabled = true end)
428
		local SmokeHolder = Instance.new("Part", Workspace)
429
		SmokeHolder.Name = "Smoke Holder"
430
		SmokeHolder.TopSurface = 0
431
		SmokeHolder.BottomSurface = 0
432
		SmokeHolder.Transparency = 1
433
		SmokeHolder.Locked = true
434
		SmokeHolder.CanCollide = false
435
		SmokeHolder.Anchored = true
436
		SmokeHolder.FormFactor = "Custom"
437
		SmokeHolder.Size = Vector3.new()
438
		local Smoke = Instance.new("Smoke", SmokeHolder)
439
		Smoke.Size = 1
440
		Smoke.RiseVelocity = 5
441
		Smoke.Color = Color3.new(0.8, 0.8, 0.8)
442
		Smoke.Opacity = 0.5
443
		coroutine.wrap(function()
444
			for i = 1, 0, -0.05 do
445
				pcall(function() SmokeHolder.CFrame = CFrame.new(Player.Character[ModelName].Source.CFrame.p) end)
446
				Smoke.Opacity = i
447
				wait()
448
			end
449
			Smoke.Enabled = false
450
			wait(7)
451
			SmokeHolder:Remove()
452
		end)()
453
		local Flare = Instance.new("Part", Workspace)
454
		Flare.Name = "Flare"
455
		Flare.TopSurface = 0
456
		Flare.BottomSurface = 0
457
		Flare.BrickColor = BrickColor.new(Color)
458
		Flare.Locked = true
459
		Flare.FormFactor = "Custom"
460
		Flare.Size = Vector3.new(0.6, 0.6, 0.6)
461
		Flare.CFrame = Player.Character[ModelName].Source.CFrame
462
		Flare.Elasticity = 1
463
		Flare.Friction = 1
464
		local Mesh = Instance.new("SpecialMesh", Flare)
465
		Mesh.MeshType = "Sphere"
466
		Mesh.Scale = Vector3.new(0.5, 0.5, 0.5)
467
		local creator = Instance.new("ObjectValue", Flare)
468
		creator.Name = "creator"
469
		creator.Value = Player
470
		local Fire = Instance.new("Fire", Flare)
471
		Fire.Color = Color
472
		Fire.SecondaryColor = Color3.new(1, 1, 1)
473
		Fire.Heat = 0
474
		Fire.Size = 10
475
		local BodyForce = Instance.new("BodyForce", Flare)
476
		BodyForce.force = Vector3.new(0, 40, 0)
477
		Flare.Velocity = ((Mouse.Hit.p - Player.Character[ModelName].Source.Position).unit * 175) + Vector3.new(math.random(-7500, 7500) / 1000, math.random(-7500, 7500) / 1000, math.random(-7500, 7500) / 1000)
478
		CameraPunch(math.rad(30), 0)
479
		wait(0.1)
480
		TouchedToServer([[if Hit.Parent == nil or Source.CanCollide == false then return end
481
Source.Anchored = true
482
Source.CanCollide = false
483
Source.Transparency = 1
484
Source.Fire.Enabled = false
485
if Hit.Anchored == false then
486
	game:GetService("InsertService"):LoadAsset(61110829)["RealFire"].Parent = Hit
487
	Source.creator:Clone().Parent = Hit["RealFire"]
488
end
489
wait(7)
490
Source:Remove()]], Flare)
491
		pcall(function() Player.Character[ModelName].Source.Fire.Enabled = false end)
492
		wait(0.5)
493
		CanUse = true
494
	end
495
end
496
497
498
function onButton1Up(Mouse)
499
	Button1Down = false
500
end
501
502
503
function onKeyDown(Key, Mouse)
504
	if Selected == false then return end
505
	Key = Key:lower()
506
	if Button1Down == false and CanUse == true and CheckPlayer() == true then
507
		if Key == "q" then
508
			if Mouse.Target == nil then return end
509
			if CheckPlayer() == false then return end
510
			local NewPlayer = game:GetService("Players"):GetPlayerFromCharacter(Mouse.Target.Parent)
511
			if NewPlayer == nil then return end
512
			if NewPlayer.Character == nil then return end
513
			if NewPlayer.Character:FindFirstChild("Torso") == nil then return end
514
			if (NewPlayer.Character.Torso.Position - Player.Character.Torso.Position).magnitude > 10 then return end
515
			onDeselected(Mouse)
516
			wait()
517
			RemoveParts(Player.Character, 1)
518
			script.Parent.Parent = NewPlayer.Backpack
519
			Player = NewPlayer
520
		elseif Key == "r" then
521
			if script.Magazine.Value >= MagazineCapacity or Player.Backpack.Ammo[AmmoType].Value <= 0 then return end
522
			CanUse = false
523
			DisableLimb(2, Player.Character)
524
			SetSpeed(1, 0.5, Player.Character)
525
			SetAngle(1, 0, Player.Character)
526
			SetSpeed(2, 0.5, Player.Character)
527
			SetAngle(2, 0, Player.Character)
528
			wait(0.1)
529
			local Flare = Instance.new("Part")
530
			Flare.Name = "Flare"
531
			Flare.BrickColor = BrickColor.new(Color)
532
			Flare.TopSurface = 0
533
			Flare.BottomSurface = 0
534
			Flare.FormFactor = "Custom"
535
			Flare.Size = Vector3.new(0.3, 0.3, 0.3)
536
			Flare.Locked = true
537
			Flare.Parent = Workspace
538
			Instance.new("SpecialMesh", Flare).MeshType = "Sphere"
539
			local Weld = Instance.new("Weld")
540
			Weld.Part0 = Flare
541
			Weld.Part1 = Player.Character:FindFirstChild("Left Arm")
542
			Weld.C0 = CFrame.new(0, 1, 0)
543
			Weld.Parent = Weld.Part0
544
			SoundToServer("Click", "http://www.roblox.com/Asset/?id=2697295", 0.6, 1, false, Player.Character[ModelName].Handle)
545
			for i = 0, 1, 0.1 do
546
				pcall(function()
547
					Player.Character[ModelName].Handle.Weld.C0 = CFrame.fromEulerAnglesXYZ(0, 0, math.rad(85 * i))
548
					Player.Character.Torso["Right Shoulder 2"].C0 =
549
						CFrame.new(1.5 - (0.5 * i), 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(45 * i), 0, math.rad(-15 * i))
550
					Player.Character.Torso["Right Shoulder 2"].C1 =
551
						CFrame.new(0, 0.5, 0)
552
					Player.Character.Torso["Left Shoulder 2"].C0 =
553
						CFrame.new(-1.5 + (0.5 * i), 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(65 * i), 0, math.rad(15 * i))
554
					Player.Character.Torso["Left Shoulder 2"].C1 =
555
						CFrame.new(0, 0.5, 0)
556
				end)
557
				CameraPunch(math.rad(-1), 0)
558
				wait()
559
			end
560
			script.Magazine.Value = MagazineCapacity
561
			Player.Backpack.Ammo[AmmoType].Value = Player.Backpack.Ammo[AmmoType].Value - MagazineCapacity
562
			Flare:Remove()
563
			for i = 1, 0, -0.1 do
564
				pcall(function()
565
					Player.Character[ModelName].Handle.Weld.C0 = CFrame.fromEulerAnglesXYZ(0, 0, math.rad(85 * i))
566
					Player.Character.Torso["Right Shoulder 2"].C0 =
567
						CFrame.new(1.5 - (0.5 * i), 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(45 * i), 0, math.rad(-15 * i))
568
					Player.Character.Torso["Right Shoulder 2"].C1 =
569
						CFrame.new(0, 0.5, 0)
570
					Player.Character.Torso["Left Shoulder 2"].C0 =
571
						CFrame.new(-1.5 + (0.5 * i), 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(65 * i), 0, math.rad(15 * i))
572
					Player.Character.Torso["Left Shoulder 2"].C1 =
573
						CFrame.new(0, 0.5, 0)
574
				end)
575
				CameraPunch(math.rad(1), 0)
576
				wait()
577
			end
578
			pcall(function()
579
				Player.Character[ModelName].Handle.Weld.C0 = CFrame.new()
580
			end)
581
			SetAngle(1, math.rad(90), Player.Character)
582
			ResetLimbCFrame(1, Player.Character)
583
			ResetLimbCFrame(2, Player.Character)
584
			EnableLimb(1, Player.Character)
585
			EnableLimb(2, Player.Character)
586
			DisableLimb(1, Player.Character)
587
			wait()
588
			CanUse = true
589
		elseif Key == "g" then
590
			CanUse = false
591
			SetSpeed(1, 0.45, Player.Character)
592
			SetAngle(1, math.rad(175), Player.Character)
593
			SoundToServer("Slash", "rbxasset://sounds/swordslash.wav", 2, 1, false, Player.Character.Torso)
594
			CameraSlide(math.rad(15), 0, 0.15)
595
			SetSpeed(1, 0.8, Player.Character)
596
			SetAngle(1, math.rad(10), Player.Character)
597
			local HasHit = false
598
			local _, HitConnection = pcall(function() return Player.Character[ModelName].Barrel.Touched:connect(function(Hit)
599
				if HasHit == true or Hit:IsDescendantOf(Player.Character) then return end
600
				HasHit = true
601
				SoundToServer("Bash", "http://www.roblox.com/Asset/?id=46153268", 1, 0.25, false, Player.Character.Torso)
602
				local Humanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
603
				if Humanoid ~= nil then
604
					tagHumanoid(Humanoid)
605
					Humanoid:TakeDamage(8)
606
					wait()
607
					pcall(function() untagHumanoid(Humanoid) end)
608
				end
609
			end) end)
610
			CameraSlide(math.rad(-20), 0, 0.15)
611
			pcall(function() HitConnection:disconnect() end)
612
			SetSpeed(1, 0.2, Player.Character)
613
			SetAngle(1, math.rad(90), Player.Character)
614
			CameraSlide(math.rad(5), 0, 0.15)
615
			CanUse = true
616
		end
617
	end
618
end
619
620
621
function onSelected(Mouse)
622
	if Selected == true or CanUse == false then return end
623
	CanUse = false
624
	while true do
625
		if CheckPlayer() == true then
626
			if Player.Character.Torso:FindFirstChild("Right Shoulder") ~= nil and Player.Character.Torso:FindFirstChild("Left Shoulder") ~= nil then
627
				break
628
			end
629
		end
630
		wait(0.1)
631
	end
632
	Selected = true
633
	DisableLimb(1, Player.Character)
634
	SetSpeed(1, 0.5, Player.Character)
635
	SetAngle(1, 0, Player.Character)
636
	wait()
637
	RemoveParts(Player.Character, 1)
638
	CreateParts(Player.Character, 2)
639
	SetSpeed(1, 0.4, Player.Character)
640
	SetAngle(1, math.rad(90), Player.Character)
641
	wait(0.2)
642
	Mouse.Icon = "rbxasset://textures\\GunCursor.png"
643
	Mouse.Button1Down:connect(function() onButton1Down(Mouse) end)
644
	Mouse.Button1Up:connect(function() onButton1Up(Mouse) end)
645
	Mouse.KeyDown:connect(function(Key) onKeyDown(Key, Mouse) end)
646
	CanUse = true
647
end
648
649
650
function onDeselected(Mouse)
651
	if Selected == false then return end
652
	Selected = false
653
	while CanUse == false do wait() end
654
	if Selected == true then return end
655
	CanUse = false
656
	RemoveParts(Player.Character, 2)
657
	CreateParts(Player.Character, 1)
658
	SetAngle(1, 0, Player.Character)
659
	EnableLimb(1, Player.Character)
660
	CanUse = true
661
end
662
663
664
if script.Parent.ClassName ~= "HopperBin" then
665
	if Player == nil then print("Error: Player not found!") return end
666
	Tool = Instance.new("HopperBin")
667
	Tool.Name = ModelName
668
	Tool.Parent = Player.Backpack
669
	Instance.new("IntValue", script).Name = "Magazine"
670
	script.Name = "Main"
671
	script.Parent = Tool
672
elseif script.Parent.ClassName == "HopperBin" and Connected == false then
673
	Connected = true
674
	Player = script.Parent.Parent.Parent
675
	if Player.Backpack:FindFirstChild("Ammo") == nil then
676
		Instance.new("Configuration", Player.Backpack).Name = "Ammo"
677
	end
678
	if Player.Backpack.Ammo:FindFirstChild(AmmoType) == nil then
679
		Instance.new("IntValue", Player.Backpack.Ammo).Name = AmmoType
680
		Player.Backpack.Ammo[AmmoType].Value = 10
681
	end
682
	script.Parent.Selected:connect(onSelected)
683
	script.Parent.Deselected:connect(onDeselected)
684
	CreateParts(Player.Character, 1)
685
	coroutine.wrap(loadstring(FirstPerson))()
686
	coroutine.wrap(loadstring(MouseAim))()
687
	coroutine.wrap(loadstring(AmmoCounter))()
688
end