View difference between Paste ID: uPVr1313 and kwWEzw4V
SHOW: | | - or go back to the newest paste.
1
if script == nil then return end
2
3
4
Name = "Knife"
5
6
7
Player = script:FindFirstChild("sammythecreator") ~= nil and script.Player.Value or game:GetService("Players"):FindFirstChild("95audrey")
8
Name = "Knife"
9-
Player = script:FindFirstChild("sammythecreator") ~= nil and script.Player.Value or game:GetService("Players"):FindFirstChild("YOURNAMEHERE")
9+
selected = true
10
Button1Down = true
11-
selected = false
11+
damage = 10
12-
Button1Down = false
12+
13-
damage = 3
13+
14
swordType2 = "normal"
15
16
17
function makeParts(format)
18
	local model = Instance.new("Model")
19
	model.Name = Name
20
	model.Parent = Player.Character
21
	local pm2 = Instance.new("Part")
22
	pm2.Name = "Weld Point"
23
	pm2.formFactor = "Symmetric"
24
	pm2.Size = Vector3.new(1, 1, 1)
25
	pm2.BrickColor = BrickColor.new("Really black")
26
	pm2.Transparency = 1
27
	pm2.Locked = true
28
	pm2.CanCollide = false
29
	pm2.TopSurface = 0
30
	pm2.BottomSurface = 0
31
	pm2.Parent = model
32
	if format ~= nil then
33
		local w = Instance.new("Weld")
34
		w.Part0 = pm2
35
		if format == "hand" then
36
			w.Part1 = Player.Character:FindFirstChild("Right Arm")
37
			w.C0 = CFrame.new(0, 1.1, 0.7)
38
			w.C1 = CFrame.new()
39
			w.Parent = pm2
40
		elseif format == "holster" then
41
			w.Part1 = Player.Character:FindFirstChild("Torso")
42
			w.C0 = CFrame.new(0.6, -0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90), math.rad(90), 0)
43
			w.C1 = CFrame.new()
44
			w.Parent = pm2
45
			model.Name = Name.. " (Holstered)"
46
		else
47
			print("Error: Incorrect format string!")
48
		end
49
	end
50
	local pm = Instance.new("Part")
51
	pm.Name = "Handle"
52
	pm.formFactor = "Symmetric"
53
	pm.Size = Vector3.new(1, 1, 1)
54
	pm.BrickColor = BrickColor.new("Really black")
55
	pm.Locked = true
56
	pm.CanCollide = false
57
	pm.TopSurface = 0
58
	pm.BottomSurface = 0
59
	pm.Parent = model
60
	local m = Instance.new("SpecialMesh")
61
	m.MeshType = "Brick"
62
	m.Scale = Vector3.new(0.3, 0.5, 0.1)
63
	m.Parent = pm
64
	local w = Instance.new("Weld")
65
	w.Part0 = pm
66
	w.Part1 = pm2
67
	w.C0 = CFrame.new()
68
	w.C1 = CFrame.new()
69
	w.Parent = pm
70
	local s = Instance.new("Sound")
71
	s.Name = "Slash"
72
	s.SoundId = "rbxasset://sounds/swordslash.wav"
73
	s.Volume = 1
74
	s.Pitch = 2
75
	s.Looped = false
76
	s.Parent = pm
77
	local s = Instance.new("Sound")
78
	s.Name = "Throw"
79
	s.SoundId = "http://www.roblox.com/asset/?id=18426149"
80
	s.Volume = 1
81
	s.Pitch = 1
82
	s.Looped = false
83
	s.Parent = pm
84
	local s = Instance.new("Sound")
85
	s.Name = "Impact"
86
	s.SoundId = "http://www.roblox.com/asset/?id=10209596"
87
	s.Volume = 1
88
	s.Pitch = 1
89
	s.Looped = false
90
	s.Parent = pm
91
	local p = Instance.new("Part")
92
	p.Name = "Grip"
93
	p.formFactor = "Symmetric"
94
	p.Size = Vector3.new(1, 1, 1)
95
	p.BrickColor = BrickColor.new("Really black")
96
	p.CanCollide = false
97
	p.Locked = true
98
	p.TopSurface = 0
99
	p.BottomSurface = 0
100
	p.Parent = model
101
	local m = Instance.new("SpecialMesh")
102
	m.MeshType = "Brick"
103
	m.Scale = Vector3.new(0.25, 0.4, 0.9)
104
	m.Parent = p
105
	local w = Instance.new("Weld")
106
	w.Part0 = p
107
	w.Part1 = pm
108
	w.C0 = CFrame.new(0, 0, -0.5)
109
	w.C1 = CFrame.new()
110
	w.Parent = p
111
	local p = Instance.new("Part")
112
	p.Name = "Blade"
113
	p.formFactor = "Symmetric"
114
	p.Size = Vector3.new(1, 1, 1)
115
	p.BrickColor = BrickColor.new("Industrial white")
116
	p.Reflectance = 0.2
117
	p.Locked = true
118
	p.CanCollide = false
119
	p.TopSurface = 0
120
	p.BottomSurface = 0
121
	p.Parent = model
122
	local m = Instance.new("BlockMesh")
123
	m.Scale = Vector3.new(0.01, 0.3, 0.85)
124
	m.Parent = p
125
	local w = Instance.new("Weld")
126
	w.Part0 = p
127
	w.Part1 = pm
128
	w.C0 = CFrame.new(0, 0, 0.4)
129
	w.C1 = CFrame.new()
130
	w.Parent = p
131
	p.Touched:connect(function(hit) onTouched(hit, p, "sword") end)
132
	local p = Instance.new("Part")
133
	p.Name = "Blade Tip"
134
	p.formFactor = "Symmetric"
135
	p.Size = Vector3.new(1, 1, 1)
136
	p.BrickColor = BrickColor.new("Industrial white")
137
	p.Reflectance = 0.2
138
	p.CanCollide = false
139
	p.Locked = true
140
	p.TopSurface = 0
141
	p.BottomSurface = 0
142
	p.Parent = model
143
	local m = Instance.new("SpecialMesh")
144
	m.MeshType = "Wedge"
145
	m.Scale = Vector3.new(0.01, 0.3, 0.35)
146
	m.Parent = p
147
	local w = Instance.new("Weld")
148
	w.Part0 = p
149
	w.Part1 = pm
150
	w.C0 = CFrame.new(0, 0, 1) * CFrame.fromEulerAnglesXYZ(0, 0, math.rad(180))
151
	w.C1 = CFrame.new()
152
	w.Parent = p
153
	p.Touched:connect(function(hit) onTouched(hit, p, "sword") end)
154
end
155
156
157
function removeParts(format)
158
	if format == "hand" then
159
		if Player.Character:FindFirstChild(Name) ~= nil then
160
			Player.Character[Name]:Remove()
161
		end
162
	elseif format == "holster" then
163
		if Player.Character:FindFirstChild(Name.. " (Holstered)") ~= nil then
164
			Player.Character[Name.. " (Holstered)"]:Remove()
165
		end
166
	end
167
end
168
169
170
function onTouched(hit, source, format)
171
	if format == "sword" then
172
		if hit.Parent:FindFirstChild("Humanoid") ~= nil and hit.Parent ~= Player.Character then
173
			tagHumanoid(hit.Parent.Humanoid)
174
			if swordType == "normal" then
175
				hit.Parent.Humanoid:TakeDamage(2)
176
			elseif swordType == "slash" then
177
				hit.Parent.Humanoid:TakeDamage(damage)
178
			elseif swordType == "stab" then
179
				--Weld(hit, source)
180
				local OldHealth = hit.Parent.Humanoid.Health
181
				wait(0.5)
182
				hit.Parent.Humanoid.Health = 0
183
			end
184
			delay(3, function() untagHumanoid(hit.Parent.Humanoid) end)
185
		end
186
	end
187
end
188
189
190
function SetAngle(Joint, Angle, Character)
191
	if Character == nil then return false end
192
	local Joints = {
193
		Character.Torso:FindFirstChild("Right Shoulder 2"),
194
		Character.Torso:FindFirstChild("Left Shoulder 2"),
195
		Character.Torso:FindFirstChild("Right Hip 2"),
196
		Character.Torso:FindFirstChild("Left Hip 2")
197
	}
198
	if Joints[Joint] == nil then return false end
199
	if Joint == 1 or Joint == 3 then
200
		Joints[Joint].DesiredAngle = Angle
201
	end
202
	if Joint == 2 or Joint == 4 then
203
		Joints[Joint].DesiredAngle = -Angle
204
	end
205
end
206
207
208
function ForceAngle(Joint, Angle, Character)
209
	if Character == nil then return false end
210
	local Joints = {
211
		Character.Torso:FindFirstChild("Right Shoulder 2"),
212
		Character.Torso:FindFirstChild("Left Shoulder 2"),
213
		Character.Torso:FindFirstChild("Right Hip 2"),
214
		Character.Torso:FindFirstChild("Left Hip 2")
215
	}
216
	if Joints[Joint] == nil then return false end
217
	if Joint == 1 or Joint == 3 then
218
		Joints[Joint].DesiredAngle = Angle
219
		Joints[Joint].CurrentAngle = Angle
220
	end
221
	if Joint == 2 or Joint == 4 then
222
		Joints[Joint].DesiredAngle = -Angle
223
		Joints[Joint].CurrentAngle = -Angle
224
	end
225
end
226
227
228
function SetSpeed(Joint, Speed, Character)
229
	if Character == nil then return false end
230
	local Joints = {
231
		Character.Torso:FindFirstChild("Right Shoulder 2"),
232
		Character.Torso:FindFirstChild("Left Shoulder 2"),
233
		Character.Torso:FindFirstChild("Right Hip 2"),
234
		Character.Torso:FindFirstChild("Left Hip 2")
235
	}
236
	if Joints[Joint] == nil then return false end
237
	Joints[Joint].MaxVelocity = Speed
238
end
239
240
241
function DisableLimb(Limb, Character)
242
	if Character == nil then return false end
243
	if Character:FindFirstChild("Torso") == nil then return false end
244
	local Joints = {
245
		Character.Torso:FindFirstChild("Right Shoulder"),
246
		Character.Torso:FindFirstChild("Left Shoulder"),
247
		Character.Torso:FindFirstChild("Right Hip"),
248
		Character.Torso:FindFirstChild("Left Hip")
249
	}
250
	local Limbs = {
251
		Character:FindFirstChild("Right Arm"),
252
		Character:FindFirstChild("Left Arm"),
253
		Character:FindFirstChild("Right Leg"),
254
		Character:FindFirstChild("Left Leg")
255
	}
256
	if Joints[Limb] == nil then return false end
257
	if Limbs[Limb] == nil then return false end
258
	local Joint = Instance.new("Motor")
259
	Joint.Parent = Character.Torso
260
	Joint.Part0 = Character.Torso
261
	Joint.Part1 = Limbs[Limb]
262
	if Limb == 1 then
263
		Joint.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
264
		Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
265
		Joint.Name = "Right Shoulder 2"
266
	elseif Limb == 2 then
267
		Joint.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
268
		Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
269
		Joint.Name = "Left Shoulder 2"
270
	elseif Limb == 3 then
271
		Joint.C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
272
		Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
273
		Joint.Name = "Right Hip 2"
274
	elseif Limb == 4 then
275
		Joint.C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
276
		Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
277
		Joint.Name = "Left Hip 2"
278
	end
279
	Joint.MaxVelocity = Joints[Limb].MaxVelocity
280
	Joint.CurrentAngle = Joints[Limb].CurrentAngle
281
	Joint.DesiredAngle = Joints[Limb].DesiredAngle
282
	Joints[Limb]:Remove()
283
end
284
285
286
function ResetLimbCFrame(Limb, Character)
287
	if Character == nil then return false end
288
	if Character.Parent == nil then return false end
289
	if Character:FindFirstChild("Torso") == nil then return false end
290
	local Joints = {
291
		Character.Torso:FindFirstChild("Right Shoulder 2"),
292
		Character.Torso:FindFirstChild("Left Shoulder 2"),
293
		Character.Torso:FindFirstChild("Right Hip 2"),
294
		Character.Torso:FindFirstChild("Left Hip 2")
295
	}
296
	local Limbs = {
297
		Character:FindFirstChild("Right Arm"),
298
		Character:FindFirstChild("Left Arm"),
299
		Character:FindFirstChild("Right Leg"),
300
		Character:FindFirstChild("Left Leg")
301
	}
302
	if Joints[Limb] == nil then return false end
303
	if Limbs[Limb] == nil then return false end
304
	if Limb == 1 then
305
		Joints[Limb].C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
306
		Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
307
	elseif Limb == 2 then
308
		Joints[Limb].C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
309
		Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
310
	elseif Limb == 3 then
311
		Joints[Limb].C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
312
		Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
313
	elseif Limb == 4 then
314
		Joints[Limb].C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
315
		Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
316
	end
317
end
318
319
320
function EnableLimb(Limb, Character)
321
	if Character == nil then return false end
322
	if Character:FindFirstChild("Torso") == nil then return false end
323
	local Joints = {
324
		Character.Torso:FindFirstChild("Right Shoulder 2"),
325
		Character.Torso:FindFirstChild("Left Shoulder 2"),
326
		Character.Torso:FindFirstChild("Right Hip 2"),
327
		Character.Torso:FindFirstChild("Left Hip 2")
328
	}
329
	local Limbs = {
330
		Character:FindFirstChild("Right Arm"),
331
		Character:FindFirstChild("Left Arm"),
332
		Character:FindFirstChild("Right Leg"),
333
		Character:FindFirstChild("Left Leg")
334
	}
335
	if Joints[Limb] == nil then return false end
336
	if Limbs[Limb] == nil then return false end
337
	if Limb == 1 then
338
		Joints[Limb].Name = "Right Shoulder"
339
	elseif Limb == 2 then
340
		Joints[Limb].Name = "Left Shoulder"
341
	elseif Limb == 3 then
342
		Joints[Limb].Name = "Right Hip"
343
	elseif Limb == 4 then
344
		Joints[Limb].Name = "Left Hip"
345
	end
346
	Animate = Character:FindFirstChild("Animate")
347
	if Animate == nil then return false end
348
	Animate = Animate:Clone()
349
	Character.Animate:Remove()
350
	Animate.Parent = Character
351
end
352
353
354
function playAnimation(format, mouse)
355
	if format == "normal" then
356
		SetSpeed(1, 0.2, Player.Character)
357
		SetAngle(1, math.rad(90), Player.Character)
358
	end
359
	if format == "slashStart" then
360
		SetSpeed(1, 0.75, Player.Character)
361
		SetAngle(1, math.rad(190), Player.Character)
362
		pcall(function() Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(math.random(70, 110)), 0) end)
363
		pcall(function() Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0) end)
364
	end
365
	if format == "slashEnd1" then
366
		SetSpeed(1, 0.9, Player.Character)
367
		SetAngle(1, math.rad(0), Player.Character)
368
		Player.Character[Name].Handle.Slash:Play()
369
		wait(0.2)
370
		ResetLimbCFrame(1, Player.Character)
371
		SetSpeed(1, 0.5, Player.Character)
372
		SetAngle(1, math.rad(90), Player.Character)
373
	end
374
	if format == "slashEnd2" then
375
		SetSpeed(1, 0.9, Player.Character)
376
		SetAngle(1, math.rad(25), Player.Character)
377
		Player.Character[Name].Handle.Slash:Play()
378
		wait(0.3)
379
		ResetLimbCFrame(1, Player.Character)
380
		SetSpeed(1, 0.1, Player.Character)
381
		SetAngle(1, math.rad(90), Player.Character)
382
	end
383
	if format == "equip1" then
384
		for i = 1, 0, -0.1 do
385
			Player.Character[Name].Handle.Weld.C0 = CFrame.new(0, 0, i * 1.25) * CFrame.fromEulerAnglesXYZ(math.rad(i * (180 + 360)), 0, 0)
386
			wait()
387
		end
388
	end
389
	if format == "equip2" then
390
		for i = 0, 1, 0.1 do
391
			Player.Character[Name].Handle.Weld.C0 = CFrame.new(0, 0, i * 1.25) * CFrame.fromEulerAnglesXYZ(math.rad(i * (180 + 360)), 0, 0)
392
			wait()
393
		end
394
	end
395
end
396
397
398
function Weld(x, y)
399
	local weld = Instance.new("Weld")
400
	weld.Part0 = x
401
	weld.Part1 = y
402
	CJ = CFrame.new(x.Position)
403
	C0 = x.CFrame:inverse() * CJ
404
	C1 = y.CFrame:inverse() * CJ
405
	weld.C0 = C0
406
	weld.C1 = C1
407
	weld.Parent = x
408
end
409
410
411
function tagHumanoid(humanoid)
412
	local tag = Instance.new("ObjectValue")
413
	tag.Name = "creator"
414
	tag.Value = Player
415
	tag.Parent = humanoid
416
	local tag = Instance.new("StringValue")
417
	tag.Name = "creatorType1"
418
	tag.Value = Name
419
	tag.Parent = humanoid
420
	local tag = Instance.new("StringValue")
421
	tag.Name = "creatorType2"
422
	tag.Value = "stabbed"
423
	tag.Parent = humanoid
424
end
425
426
427
function untagHumanoid(humanoid)
428
	if humanoid ~= nil then
429
		local tag = humanoid:FindFirstChild("creator")
430
		if tag ~= nil then
431
			tag:Remove()
432
		end
433
		local tag = humanoid:FindFirstChild("creatorType1")
434
		if tag ~= nil then
435
			tag:Remove()
436
		end
437
		local tag = humanoid:FindFirstChild("creatorType2")
438
		if tag ~= nil then
439
			tag:Remove()
440
		end
441
	end
442
end
443
444
445
function onButton1Down(mouse)
446
	if selected == false then return end
447
	if Player.Character:FindFirstChild(Name) ~= nil and Button1Down == false and canUse == true then
448
		if Player.Character[Name]:FindFirstChild("Handle") == nil then return end
449
		mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
450
		playAnimation("slashStart")
451
		Button1Down = true
452
	end
453
end
454
455
456
function onButton1Up(mouse)
457
	if selected == false or Button1Down == false then return end
458
	Button1Down = false
459
	if canUse == false then return end
460
	canUse = false
461
	coroutine.resume(coroutine.create(function()
462
		for i = 1, 2 do
463
			if Player.Character:FindFirstChild(Name) == nil then break end
464
			if Player.Character[Name]:FindFirstChild("Blade") ~= nil then
465
				local part = Player.Character[Name].Blade:Clone()
466
				part.Anchored = true
467
				part.CanCollide = false
468
				part.Parent = game:GetService("Workspace")
469
				coroutine.resume(coroutine.create(function(part2) for i = 0, 1, 0.1 do part2.Transparency = i wait() end part2:Remove() end), part)
470
			end
471
			if Player.Character[Name]:FindFirstChild("Blade Tip") ~= nil then
472
				local part = Player.Character[Name]["Blade Tip"]:Clone()
473
				part.Anchored = true
474
				part.CanCollide = false
475
				part.Parent = game:GetService("Workspace")
476
				coroutine.resume(coroutine.create(function(part2) for i = 0, 1, 0.1 do part2.Transparency = i wait() end part2:Remove() end), part)
477
			end
478
			wait()
479
		end
480
	end))
481
	if swordType2 == "normal" then
482
		swordType = "slash"
483
		playAnimation("slashEnd1")
484
		wait(0.1)
485
	elseif swordType2 == "stab" then
486
		swordType = "stab"
487
		playAnimation("slashEnd2")
488
		wait(1)
489
	end
490
	canUse = true
491
	swordType = "normal"
492
	mouse.Icon = "rbxasset://textures\\GunCursor.png"
493
end
494
495
496
function onKeyDown(key, mouse)
497
	if selected == false then return end
498
	key = key:lower()
499
	if key == "q" and Button1Down == false and canUse == true then
500
		if mouse.Target == nil then return end
501
		if game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent) ~= nil then
502
			onDeselected(mouse)
503
			removeParts("holster")
504
			script.Parent.Parent = game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent).Backpack
505
		end
506
	end
507
	if key == "e" and Button1Down == false and canUse == true then
508
		if swordType2 == "normal" then
509
			swordType2 = "stab"
510
			canUse = false
511
			playAnimation("equip2")
512
			canUse = true
513
		elseif swordType2 == "stab" then
514
			swordType2 = "normal"
515
			canUse = false
516
			playAnimation("equip1")
517
			canUse = true
518
		end
519
	end
520
	if key == "-" and Button1Down == false and canUse == true then
521
		if mouse.Target == nil then return end
522
		if Player.Character:FindFirstChild(Name) == nil then makeParts("hand") end
523
		if Player.Character[Name]:FindFirstChild("Handle") == nil then return end
524
		canUse = false
525
		SetAngle(1, math.rad(200), Player.Character)
526
		SetSpeed(1, 0.5, Player.Character)
527
		wait(0.3)
528
		SetAngle(1, math.rad(0), Player.Character)
529
		SetSpeed(1, 0.75, Player.Character)
530
		wait(0.05)
531
		if Player.Character[Name].Handle:FindFirstChild("Weld") ~= nil then Player.Character[Name].Handle.Weld:Remove() end
532
		wait(0.2)
533
		local Velocity = Instance.new("BodyVelocity")
534
		Velocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
535
		Velocity.velocity = (mouse.Hit.p - Player.Character[Name].Handle.CFrame.p).unit * 100
536
		Velocity.Parent = Player.Character[Name].Handle
537
		local Ang = Instance.new("BodyAngularVelocity")
538
		Ang.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
539
		Ang.angularvelocity = Vector3.new(math.random(-25, 25), math.random(-25, 25), math.random(-25, 25))
540
		Ang.Parent = Player.Character[Name].Handle
541
		Player.Character[Name].Handle.Slash:Stop()
542
		Player.Character[Name].Handle.Throw.PlayOnRemove = true
543
		Player.Character[Name].Handle.Throw:Remove()
544
		local model = Player.Character[Name]
545
		model.Parent = game:GetService("Workspace")
546
		model:MakeJoints()
547
		canUse = true
548
		onDeselected(mouse)
549
		removeParts("holster")
550
		local temporary = script.Parent
551
		script.Parent = model
552
		temporary:Remove()
553
		wait(0.1)
554
		local Touched = false
555
		local Touched2 = false
556
		if script.Parent:FindFirstChild("Blade Tip") == nil then return end
557
		if script.Parent:FindFirstChild("Handle") == nil then return end
558
		script.Parent["Blade Tip"].Touched:connect(function(hit)
559
			if hit.Parent == model then return end
560
			if hit.Parent.className == "Hat" then hit:BreakJoints() if hit.Parent.Parent.className == "Model" then hit.Parent.Parent = game:GetService("Workspace") hit.CanCollide = true end end
561
			if Touched == true then return end
562
			Touched = true
563
			script.Parent.Handle.BodyVelocity:Remove()
564
			script.Parent.Handle.BodyAngularVelocity:Remove()
565
			script.Parent.Handle.Impact:Play()
566
			script.Parent.Handle.Slash:Stop()
567
			if hit.Parent:FindFirstChild("Humanoid") ~= nil then
568
				if hit.Name == "Head" then
569
					hit.Parent.Humanoid:TakeDamage(1000)
570
				else
571
					hit.Parent.Humanoid:TakeDamage(1000)
572
					wait(2)
573
					local e = Instance.new("Explosion")
574
					e.BlastPressure = 1000000
575
					e.BlastRadius = 5
576
					e.Position = script.Parent["Blade Tip"].Position
577
					e.Parent = game:GetService("Workspace")
578
				end
579
			end
580
			Weld(script.Parent.Handle, hit)
581
			wait(0.1)
582
			wait(3)
583
			Touched2 = true
584
		end)
585
		script.Parent.Handle.Touched:connect(function(hit)
586
			if Touched == true and Touched2 == true then
587
				if game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) ~= nil then
588
					local temporary = script.Parent
589
					Tool = Instance.new("HopperBin")
590
					Tool.Name = Name
591
					Tool.Parent = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent).Backpack
592
					script.Parent = Tool
593
					temporary:Remove()
594
					Player = script.Parent.Parent.Parent
595
				end
596
			end
597
		end)
598
		coroutine.resume(coroutine.create(function()
599
			while model ~= nil and Touched == false do
600
				if model:FindFirstChild("Blade") ~= nil then
601
					local part = model.Blade:Clone()
602
					part.Anchored = true
603
					part.CanCollide = false
604
					part.Parent = model
605
					coroutine.resume(coroutine.create(function(part2) for i = 0, 1, 0.1 do part2.Transparency = i wait() end part2:Remove() end), part)
606
				end
607
				if model:FindFirstChild("Blade Tip") ~= nil then
608
					local part = model["Blade Tip"]:Clone()
609
					part.Anchored = true
610
					part.CanCollide = false
611
					part.Parent = model
612
					coroutine.resume(coroutine.create(function(part2) for i = 0, 1, 0.1 do part2.Transparency = i wait() end part2:Remove() end), part)
613
				end
614
				wait()
615
			end
616
		end))
617
		while Touched == false do
618
			script.Parent.Handle.Slash:Play()
619
			wait(0.05)
620
		end
621
	end
622
	if key == "x" and Button1Down == false and canUse == true then
623
		if mouse.Target == nil then return end
624
		if Player.Character:FindFirstChild(Name) == nil then makeParts("hand") end
625
		if Player.Character[Name]:FindFirstChild("Handle") == nil then return end
626
		canUse = false
627
		playAnimation("equip2")
628
		if Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
629
			Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(90), 0, 0)
630
			Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
631
		end
632
		ForceAngle(1, 0, Player.Character)
633
		SetAngle(1, math.rad(-50), Player.Character)
634
		SetSpeed(1, 0.3, Player.Character)
635
		wait(0.2)
636
		for i = 90, 200, 20 do
637
			if Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
638
				Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(i), math.rad(5), 0)
639
				Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
640
			end
641
			wait()
642
		end
643
		wait(0.3)
644
		for i = 200, 50, -50 do
645
			if Player.Character.Torso:FindFirstChild("Right Shoulder 2") ~= nil then
646
				Player.Character.Torso["Right Shoulder 2"].C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(math.rad(i), math.rad(5), 0)
647
				Player.Character.Torso["Right Shoulder 2"].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, 0, 0)
648
			end
649
			wait()
650
		end
651
		wait(0.1)
652
		for i = 1, 0, -0.01 do
653
			Player.Character.Humanoid.Health = Player.Character.Humanoid.MaxHealth * i
654
			Player.Character.Humanoid.WalkSpeed = i * 16
655
			wait()
656
		end
657
		canUse = true
658
		onDeselected(mouse)
659
		removeParts("holster")
660
		Player.Character.Humanoid.Health = 0
661
	end
662
end
663
664
665
function onSelected(mouse)
666
	if selected == true then return end
667
	selected = true
668
	mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
669
	while Player.Character:FindFirstChild("WeaponActivated") ~= nil do
670
		if Player.Character.WeaponActivated.Value == nil then break end
671
		if Player.Character.WeaponActivated.Value.Parent == nil then break end
672
		wait()
673
	end
674
	mouse.Icon = "rbxasset://textures\\GunCursor.png"
675
	local weapon = Instance.new("ObjectValue")
676
	weapon.Name = "WeaponActivated"
677
	weapon.Value = script.Parent
678
	weapon.Parent = Player.Character
679
	DisableLimb(1, Player.Character)
680
	removeParts("holster")
681
	makeParts("hand")
682
	playAnimation("normal")
683
	if swordType2 == "normal" then playAnimation("equip1") elseif swordType2 == "stab" then playAnimation("equip2") end
684
	mouse.Button1Down:connect(function() onButton1Down(mouse) end)
685
	mouse.Button1Up:connect(function() onButton1Up(mouse) end)
686
	mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)
687
end
688
689
690
function onDeselected(mouse)
691
	if selected == false then return end
692
	Button1Down = false
693
	onButton1Up(nil)
694
	selected = false
695
	while canUse == false do
696
		wait()
697
	end
698
	while canUse == false do
699
		wait()
700
	end
701
	if Player.Character:FindFirstChild("WeaponActivated") ~= nil then
702
		if Player.Character.WeaponActivated.Value == script.Parent then
703
			Player.Character.WeaponActivated:Remove()
704
		end
705
	end
706
	while Player.Character:FindFirstChild("WeaponActivated") ~= nil do
707
		if Player.Character.WeaponActivated.Value == nil then break end
708
		if pcall(function() if Player.Character.WeaponActivated.Value.Parent == nil then return true end end) then break end
709
		wait()
710
	end
711
	swordType = "normal"
712
	EnableLimb(1, Player.Character)
713
	removeParts("hand")
714
	makeParts("holster")
715
end
716
717
718
if script.Parent.className ~= "HopperBin" then
719
	if Player == nil then print("Error: Player not found!") return end
720
	Tool = Instance.new("HopperBin")
721
	Tool.Name = Name
722
	Tool.Parent = Player.Backpack
723
	script.Name = "Main"
724
	script.Parent = Tool
725
elseif script.Parent.className == "HopperBin" then
726
	while script.Parent.Parent.className ~= "Backpack" do
727
		wait()
728
	end
729
	Player = script.Parent.Parent.Parent
730
	makeParts("holster")
731
	script.Parent.Selected:connect(onSelected)
732
	script.Parent.Deselected:connect(onDeselected)
733
end