View difference between Paste ID: WvNb6JK7 and NaGF8kjU
SHOW: | | - or go back to the newest paste.
1
if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
2
local Player,game,owner = owner,game
3
local RealPlayer = Player
4
do
5
	print("FE Compatibility code V2 by Mokiros")
6
	local RealPlayer = RealPlayer
7
	script.Parent = RealPlayer.Character
8
9
	--Fake event to make stuff like Mouse.KeyDown work
10
	local Disconnect_Function = function(this)
11
		this[1].Functions[this[2]] = nil
12
	end
13
	local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}}
14
	local FakeEvent_Metatable = {__index={
15
		Connect = function(this,f)
16
			local i = tostring(math.random(0,10000))
17
			while this.Functions[i] do
18
				i = tostring(math.random(0,10000))
19
			end
20
			this.Functions[i] = f
21
			return setmetatable({this,i},Disconnect_Metatable)
22
		end
23
	}}
24
	FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect
25
	local function fakeEvent()
26
		return setmetatable({Functions={}},FakeEvent_Metatable)
27
	end
28
29
	--Creating fake input objects with fake variables
30
    local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
31
    FakeMouse.keyUp = FakeMouse.KeyUp
32
    FakeMouse.keyDown = FakeMouse.KeyDown
33
	local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
34
	local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
35
		CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
36
	end}
37
	--Merged 2 functions into one by checking amount of arguments
38
	CAS.UnbindAction = CAS.BindAction
39
40
	--This function will trigger the events that have been :Connect()'ed
41
	local function TriggerEvent(self,ev,...)
42
		for _,f in pairs(self[ev].Functions) do
43
			f(...)
44
		end
45
	end
46
	FakeMouse.TriggerEvent = TriggerEvent
47
	UIS.TriggerEvent = TriggerEvent
48
49
	--Client communication
50
	local Event = Instance.new("RemoteEvent")
51
	Event.Name = "UserInput_Event"
52
	Event.OnServerEvent:Connect(function(plr,io)
53
	    if plr~=RealPlayer then return end
54
		FakeMouse.Target = io.Target
55
		FakeMouse.Hit = io.Hit
56
		if not io.isMouse then
57
			local b = io.UserInputState == Enum.UserInputState.Begin
58
			if io.UserInputType == Enum.UserInputType.MouseButton1 then
59
				return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up")
60
			end
61
			if io.UserInputType == Enum.UserInputType.MouseButton2 then
62
				return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up")
63
			end
64
			for _,t in pairs(CAS.Actions) do
65
				for _,k in pairs(t.Keys) do
66
					if k==io.KeyCode then
67
						t.Function(t.Name,io.UserInputState,io)
68
					end
69
				end
70
			end
71
			FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
72
			UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false)
73
	    end
74
	end)
75
	Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event")
76
	local Mouse = owner:GetMouse()
77
	local UIS = game:GetService("UserInputService")
78
	local input = function(io,RobloxHandled)
79
		if RobloxHandled then return end
80
		--Since InputObject is a client-side instance, we create and pass table instead
81
		Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
82
	end
83
	UIS.InputBegan:Connect(input)
84
	UIS.InputEnded:Connect(input)
85
	local h,t
86
	--Give the server mouse data every second frame, but only if the values changed
87
	--If player is not moving their mouse, client won't fire events
88
	local HB = game:GetService("RunService").Heartbeat
89
	while true do
90
		if h~=Mouse.Hit or t~=Mouse.Target then
91
			h,t=Mouse.Hit,Mouse.Target
92
			Event:FireServer({isMouse=true,Target=t,Hit=h})
93
		end
94
		--Wait 2 frames
95
		for i=1,2 do
96
			HB:Wait()
97
		end
98
	end]==],script)
99
100
	----Sandboxed game object that allows the usage of client-side methods and services
101
	--Real game object
102
	local RealGame = game
103
104
	--Metatable for fake service
105
	local FakeService_Metatable = {
106
		__index = function(self,k)
107
			local s = rawget(self,"_RealService")
108
			if s then
109
				return typeof(s[k])=="function"
110
				and function(_,...)return s[k](s,...)end or s[k]
111
			end
112
		end,
113
		__newindex = function(self,k,v)
114
			local s = rawget(self,"_RealService")
115
			if s then s[k]=v end
116
		end
117
	}
118
	local function FakeService(t,RealService)
119
		t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
120
		return setmetatable(t,FakeService_Metatable)
121
	end
122
123
	--Fake game object
124
	local FakeGame = {
125
		GetService = function(self,s)
126
			return rawget(self,s) or RealGame:GetService(s)
127
		end,
128
		Players = FakeService({
129
			LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
130
		},"Players"),
131
		UserInputService = FakeService(UIS,"UserInputService"),
132
		ContextActionService = FakeService(CAS,"ContextActionService"),
133
		RunService = FakeService({
134
			_btrs = {},
135
			RenderStepped = RealGame:GetService("RunService").Heartbeat,
136
			BindToRenderStep = function(self,name,_,fun)
137
				self._btrs[name] = self.Heartbeat:Connect(fun)
138
			end,
139
			UnbindFromRenderStep = function(self,name)
140
				self._btrs[name]:Disconnect()
141
			end,
142
		},"RunService")
143
	}
144
	rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
145
	FakeGame.service = FakeGame.GetService
146
	FakeService(FakeGame,game)
147
	--Changing owner to fake player object to support owner:GetMouse()
148
	game,owner = FakeGame,FakeGame.Players.LocalPlayer
149
end
150
151
local tool=Instance.new("HopperBin", game.Players.LocalPlayer.Backpack)
152
tool.Name="Knife"
153
 
154
wait()
155
script.Parent=tool
156
157
--Murderer knife action script, original code from The Mad Murderer, by loleris.
158
159
wait()
160
local camera = game.Workspace.CurrentCamera
161
local player = game.Players.LocalPlayer
162
local character = player.Character
163
local humanoid = character.Humanoid
164
local head = character.Head
165
local torso = character.Torso
166
local Left_Arm = character["Left Arm"]
167
local Right_Arm = character["Right Arm"]
168
local tool = script.Parent
169
local pl_mouse = player:GetMouse()
170
171
local rs = game:GetService("RunService")
172
173
local stab_damage = 110
174
local walkspeeds = {16, 19}
175
176
Settings = {
177
	Equip_time = 0.1,
178
	Idle_speed = 8,
179
	Attack_speed = 0.6,
180
	Throw_Offset = CFrame.new(1.5, 2, -0.3),
181
	ThrowChargeDelay = 0.2,
182
	DefaultKnifeSkin = "Default",
183
	DefaultAbility = "Default",
184
	
185
	Crosshair = "rbxassetid://54019936",
186
}
187
188
local KnifeSettings = {
189
	Equip_time = 0.5,
190
	Charge_time = 1,
191
	Throw_speed = 2,
192
	
193
	ThrowDamage = 110,
194
	SlashDamage = 110,
195
	
196
	CanThrow = true,
197
	CanSlash = true,
198
}
199
200
function GetIgnoreList(checkignored)
201
	local result = {}
202
	local ignored = false
203
	if player.Character then
204
		for _,c in pairs(player.Character:GetChildren()) do
205
			if c:IsA("Part") then
206
				table.insert(result,c)
207
				if checkignored ~= nil and checkignored == c then
208
					ignored = true
209
				end
210
			elseif c:IsA("Hat") then
211
				table.insert(result,c.Handle)
212
				if checkignored ~= nil and checkignored == c or checkignored == c.Handle then
213
					ignored = true
214
				end
215
			elseif c:IsA("Tool") then
216
				if c:FindFirstChild("Handle") then
217
					table.insert(result,c.Handle)
218
					if checkignored ~= nil and checkignored == c or checkignored == c.Handle then
219
						ignored = true
220
					end
221
				end
222
			end
223
		end
224
	end
225
	for _,c in pairs(workspace:GetChildren()) do
226
		if c.Name == "WeaponObject" then
227
			table.insert(result,c)
228
			if checkignored ~= nil and checkignored == c then
229
				ignored = true
230
			end
231
		end
232
	end
233
	for _,c in pairs(camera:GetChildren()) do
234
		table.insert(result,c)
235
		if checkignored ~= nil and checkignored == c then
236
			ignored = true
237
		end
238
	end
239
	if checkignored == nil then
240
	return result
241
	else
242
	return ignored
243
	end
244
end
245
246
local assetlink = "http://www.roblox.com/asset/?id="
247
local hit_sounds = {"153647516", "153647519", "153647522", "153647526"}
248
local death_sounds = {"146594640", "146594648", "146457047"}
249
250
local Sounds = {
251
	Equip = {
252
		"153647514",
253
	},
254
	Slash = {
255
		"153647529",
256
		"153647534",
257
		"153647539",
258
		"153647540",
259
	},
260
	Throw = {
261
		"153647549",
262
		"153647554",
263
	},
264
	KnifeHitSurface = {
265
		"153647563",
266
		"153647564",
267
	},
268
	Death={
269
		"146594640", 
270
		"146457047", 
271
		"146594648",
272
		},
273
	HitPlayer={
274
		"153647516", 
275
		"153647519", 
276
		"153647522",
277
		"153647526",
278
	},
279
}
280
281
function HIT_HANDLE(hit, dmg, pos)
282
	if hit == nil then return end
283
	local h = hit.Parent:findFirstChild("Humanoid")
284
	if h == nil then
285
		h = hit.Parent.Parent:findFirstChild("Humanoid")
286
	end
287
	if h == nil then return end
288
	if h.Health <= 0 then return end
289
	
290
	local head = h.Parent:findFirstChild("Head")
291
	if head == nil then return end
292
	
293
	local sound_part = Instance.new("Part")
294
	sound_part.formFactor = "Custom"
295
	sound_part.Size = Vector3.new(0.2, 0.2, 0.2)
296
	sound_part.Transparency = 1
297
	sound_part.CanCollide = false
298
	sound_part.Anchored = true
299
	sound_part.CFrame = head.CFrame
300
	sound_part.Parent = Workspace
301
	local s_hit = Instance.new("Sound")
302
	s_hit.Volume = 1
303
	s_hit.SoundId = assetlink .. hit_sounds[math.random(1, #hit_sounds)]
304
	s_hit.Parent = sound_part
305
	local s_die = Instance.new("Sound")
306
	s_die.Volume = 1
307
	s_die.SoundId = assetlink .. death_sounds[math.random(1, #death_sounds)]
308
	s_die.Parent = sound_part
309
	
310
	s_hit:play()
311
	
312
	local c_tag = Instance.new("ObjectValue")
313
	c_tag.Name = "creator"
314
	c_tag.Value = player
315
	c_tag.Parent = h
316
	h:TakeDamage(stab_damage)
317
	
318
	if h.Health <= dmg then
319
		s_die:play()
320
	end
321
end
322
323
function RayCast(pos1, pos2, dist, ign)
324
	local ray = Ray.new(
325
		pos1,
326
		(pos2 - pos1).unit * math.abs(dist)
327
	) 
328
	local hit, hpos = Workspace:FindPartOnRayWithIgnoreList(ray, ign, false)
329
	return hit, hpos
330
end
331
332
local larm = character:findFirstChild("Left Arm")
333
local rarm = character:findFirstChild("Right Arm")
334
function Slash(del)
335
	coroutine.resume(coroutine.create(function()
336
		local hits = {}
337
		
338
		local start = tick()
339
		local actv = true
340
		
341
		local function ishitted(obj)
342
			for i = 1, #hits do
343
				if obj:IsDescendantOf(hits[i]) then
344
					return true
345
				end
346
			end
347
			return false
348
		end
349
		
350
		local function hitp(hit)
351
			if ishitted(hit) then return end
352
			local h = hit.Parent:findFirstChild("Humanoid")
353
			if h == nil then
354
				h = hit.Parent.Parent:findFirstChild("Humanoid")
355
			end
356
			if h == nil then return end
357
			hits[#hits + 1] = h.Parent
358
			HIT_HANDLE(hit, stab_damage)
359
		end
360
		
361
		local con = {
362
			larm.Touched:connect(hitp),
363
			rarm.Touched:connect(hitp),
364
		}
365
		
366
		while tick() - start <= Settings.Attack_speed do wait() end
367
		actv = false
368
		con[1]:disconnect()
369
		con[2]:disconnect()
370
	end))
371
end
372
373
local dg_sounds = {
374
	equip = {
375
		"153647514"
376
	},
377
	hit = {
378
		"153647516",
379
		"153647519",
380
		"153647522",
381
		"153647526"
382
	},
383
	Slash = {
384
		"153647529",
385
		"153647534",
386
		"153647539",
387
		"153647540"
388
	},
389
	Throw = {
390
		"153647549",
391
		"153647554",
392
	},
393
	KnifeHitSurface = {
394
		"153647563",
395
		"153647564",
396
	},
397
	Death={
398
		"146594640", 
399
		"146457047", 
400
		"146594648",
401
	},
402
}
403
404
local dg_soundobj = {}
405
for k, v in pairs(dg_sounds) do
406
	dg_soundobj[k] = {}
407
	for i = 1, #v do
408
		local ns = Instance.new("Sound")
409
		ns.SoundId = assetlink .. v[i]
410
		ns.Volume = 1
411
		dg_soundobj[k][#dg_soundobj[k] + 1] = ns
412
	end
413
end
414
415
function LoadSounds()
416
	for __, v in pairs(dg_soundobj) do
417
		for i = 1, #v do
418
			v[i].Parent = head
419
		end
420
	end
421
end
422
function RemoveSounds()
423
	for __, v in pairs(dg_soundobj) do
424
		for i = 1, #v do
425
			v[i].Parent = nil
426
		end
427
	end
428
end
429
function PlaySound(nm, dl)
430
	if dl == nil then
431
		dg_soundobj[nm][math.random(1, #dg_soundobj[nm])]:play()
432
	else
433
		coroutine.resume(coroutine.create(function()
434
			wait(dl)
435
			dg_soundobj[nm][math.random(1, #dg_soundobj[nm])]:play()
436
		end))
437
	end
438
end
439
440
local ThrowProperties = {
441
	spin = 3,
442
	min_vel = 80,
443
	max_vel = 450,
444
	min_g = 11,
445
	max_g = 17,
446
	max_time = 30,
447
	cleanup_time = 10,
448
	fade_time = 1,
449
}
450
451
function Throw(target, pw, throw_prop)
452
	throw_prop = ThrowProperties --meh
453
	coroutine.resume(coroutine.create(function()
454
		local knf = Instance.new("Part")
455
		knf.Name = "WeaponObject"
456
		knf.CanCollide = false
457
		knf.Anchored = true
458
		knf.formFactor = "Custom"
459
		knf.Size = Vector3.new(0.2, 0.2, 0.2)
460
		knf.BrickColor = character.WeaponObject.BrickColor
461
		knf.Transparency = character.WeaponObject.Transparency
462
		knf.Reflectance = character.WeaponObject.Reflectance
463
		knf.TopSurface = 0
464
		knf.BottomSurface = 0
465
		local m = Instance.new("SpecialMesh")
466
		m.MeshId = "http://www.roblox.com/asset/?id=121944778"
467
		m.TextureId = character.WeaponObject.Mesh.TextureId
468
		m.Scale = Vector3.new(0.6, 0.6, 0.6)
469
		m.Parent = knf
470
		
471
		local hit_sound = nil
472
		
473
		local hit_sound = Instance.new("Sound")
474
		hit_sound.Volume = 1
475
		hit_sound.Pitch = 1
476
		if #Sounds.KnifeHitSurface > 0 then
477
			local sel_sound = dg_sounds.KnifeHitSurface[math.random(1, #dg_sounds.KnifeHitSurface)]
478
			if type(sel_sound) == "string" then
479
				hit_sound = Instance.new("Sound")
480
				hit_sound.Volume = 1
481
				hit_sound.Pitch = 1
482
				hit_sound.SoundId = assetlink..sel_sound
483
				hit_sound.Parent = knf
484
			elseif type(sel_sound) == "table" then
485
				hit_sound = {}
486
				for _, snd in pairs(sel_sound) do
487
					local sound = Instance.new("Sound")
488
					sound.Volume = 1
489
					sound.Pitch = 1
490
					sound.SoundId = assetlink..snd
491
					sound.Parent = knf
492
					table.insert(hit_sound, sound)
493
				end
494
			end
495
		end
496
		
497
		local start_pos = character.WeaponObject.Position
498
		local trg_cf = CFrame.new(start_pos, target)
499
		local dir_vec = (trg_cf).p - (trg_cf * CFrame.new(0, 0, -1)).p
500
		local t_ang = math.abs(math.atan(math.abs(dir_vec.y / Vector2.new(dir_vec.x, dir_vec.z).magnitude)))
501
		local isneg = -dir_vec.y / math.abs(dir_vec.y)
502
		
503
		local base_cf = CFrame.new(start_pos, Vector3.new(target.x, start_pos.y, target.z))
504
		local curr_vel = throw_prop.min_vel + ((throw_prop.max_vel - throw_prop.min_vel) * pw)
505
		
506
		local curr_g = throw_prop.min_g + ((throw_prop.max_g - throw_prop.min_g) * (1 - pw))
507
		local v_h = curr_vel * math.cos(t_ang)
508
		local v_v = curr_vel * math.sin(t_ang) * isneg
509
		
510
		local function GetCf(t)
511
			return base_cf * CFrame.new(0, v_v * t - (curr_g * (t ^2) * 0.5), -v_h * t)
512
		end
513
		local function throw_rc(p1, p2)
514
			return RayCast(p1, p2, (p1 - p2).magnitude + 0.001, GetIgnoreList())
515
		end
516
		
517
		knf.Parent = workspace
518
		knf.CFrame = base_cf
519
		
520
		local hit, pos
521
		
522
		spawn(function()
523
			local flying = true
524
			local start = tick()
525
			local last_p = base_cf.p
526
			while flying and tick() - start < throw_prop.max_time do
527
				local new_ps = GetCf(tick() - start)
528
				knf.CFrame = new_ps * CFrame.Angles(math.rad(-360 * (tick() * throw_prop.spin - math.floor(tick() * throw_prop.spin))), 0, 0)
529
				local ht, ps = throw_rc(last_p, new_ps.p)
530
				if ht ~= nil and ht~=knf then
531
					hit = ht
532
					print(hit.className .. " " .. hit.Name .. " :: " .. hit.Parent.Name)
533
					pos = ps
534
					break
535
				end
536
				if humanoid.Health <= 0 then
537
					knf:remove()
538
					return
539
				end
540
				last_p = new_ps.p
541
				rs.RenderStepped:wait()
542
			end
543
			
544
			if hit == nil then
545
				knf:remove()
546
			else
547
				if not hit.Anchored then
548
					knf:remove()
549
				else
550
					knf.CFrame = CFrame.new(last_p, pos) * CFrame.new(0, 0, 0.4-(last_p - pos).magnitude) * CFrame.Angles(math.rad(-90), 0, 0)
551
					if hit_sound ~= nil then
552
						if type(hit_sound) == "table" then
553
							for _, snd_obj in pairs(hit_sound) do
554
								snd_obj:Play()
555
							end
556
						else
557
							hit_sound:Play()
558
						end
559
					end
560
				end
561
	
562
				if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Humanoid"):IsA("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid") and hit.Parent.Parent:FindFirstChild("Humanoid"):IsA("Humanoid") then
563
					if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Humanoid"):IsA("Humanoid") then
564
						HIT_HANDLE(hit, KnifeSettings.ThrowDamage, {"Throw"})
565
					else
566
						HIT_HANDLE(hit.Parent, KnifeSettings.ThrowDamage, {"Throw"})
567
					end
568
				end
569
			end
570
		end)
571
	end))
572
end
573
574
local function OnThrow(target, power) --Called when the knife is thrown
575
	Throw(target, power, ThrowProperties)
576
end
577
578
local function SlashHandle(hit) --Called when the knife is slashed
579
	if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Humanoid"):IsA("Humanoid") then
580
		if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Humanoid"):IsA("Humanoid") then
581
			HIT_HANDLE(hit, KnifeSettings.ThrowDamage, {"Slash"})
582
		else
583
			HIT_HANDLE(hit.Parent, KnifeSettings.ThrowDamage, {"Slash"})
584
		end
585
		return hit.Parent
586
	end
587
	return nil
588
	--return object to add to ignore list
589
end
590
591
_G.MurderKnife_AnimType = "Default"
592
_G.MurderKnife_AnimState = 0
593
594
function Animate(tp, st)
595
	_G.MurderKnife_AnimType = tp
596
	_G.MurderKnife_AnimState = st
597
end
598
599
function SLASH()
600
	coroutine.resume(coroutine.create(function()
601
		local hits = {}
602
		
603
		local start = tick()
604
		local actv = true
605
		
606
		local function ishitted(obj)
607
			for i = 1, #hits do
608
				if obj:IsDescendantOf(hits[i]) then
609
					return true
610
				end
611
			end
612
			return false
613
		end
614
		
615
		local function hitp(hit)
616
			if ishitted(hit) then return end
617
			if hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("Humanoid") then
618
				hit.Parent:BreakJoints()
619
			end
620
		end
621
		
622
		local con = {
623
			Left_Arm.Touched:connect(hitp),
624
			Right_Arm.Touched:connect(hitp),
625
		}
626
		
627
		while tick() - start <= Settings.Attack_speed do wait() end
628
		actv = false
629
		con[1]:disconnect()
630
		con[2]:disconnect()
631
	end))
632
end
633
634
tool.Selected:connect(function(mouse) --Default, Idle1, Idle2, Attack1, Attack2, Attack3, Charge, Throw
635
	humanoid.WalkSpeed = walkspeeds[2]
636
	mouse.Icon = assetlink .. "54019936"
637
	Animate("Charge", 0)
638
	LoadSounds()
639
	PlaySound("equip", 0.1)
640
	
641
	local anim_equip = 1
642
	local last_action = tick()
643
	local idle_rand = math.random(4, 7)
644
	local idle_perform = 0
645
	local idle_type = 1
646
	
647
	local attack_perform = 0
648
	local attack_type = 1
649
	
650
	local running = true
651
	local last_c = tick()
652
	local mouse_holding = false
653
	local throw_charge = 0
654
	local throw_perform = 0
655
	
656
	local function StartSlash()
657
		if tick() - attack_perform <= Settings.Attack_speed or tick() - throw_perform <= KnifeSettings.Throw_speed or anim_equip > 0 then return end
658
		attack_perform = tick()
659
		last_action = tick()
660
		attack_type = math.random(1, 3)
661
		idle_perform = 0
662
		SLASH()
663
		PlaySound("Slash", 0.23 * Settings.Attack_speed)
664
	end
665
	
666
	local click_start = tick()
667
	mouse.Button1Down:connect(function()
668
		mouse_holding = true
669
		if not running or anim_equip > 0 or (tick() - throw_perform) < KnifeSettings.Throw_speed then return end
670
		if KnifeSettings.CanThrow and KnifeSettings.CanSlash then --Throw and slash enabled
671
			if tick() - attack_perform <= Settings.Attack_speed or tick() - throw_perform <= KnifeSettings.Throw_speed then return end
672
			click_start = tick()
673
		elseif KnifeSettings.CanThrow then --Throw only
674
			if tick() - throw_perform <= KnifeSettings.Throw_speed then return end
675
			click_start = tick()
676
		elseif KnifeSettings.CanSlash then --Slash only
677
			StartSlash()
678
		end
679
	end)
680
	
681
	mouse.Button1Up:connect(function()
682
		mouse_holding = false
683
		if not running or anim_equip > 0 or (tick() - throw_perform) < KnifeSettings.Throw_speed then return end
684
		local clickd = tick() - click_start
685
		click_start = math.huge
686
		if KnifeSettings.CanThrow and KnifeSettings.CanSlash then --Throw and slash enabled
687
			if clickd < Settings.ThrowChargeDelay then
688
				StartSlash()
689
			else
690
				PlaySound("Throw")
691
				throw_perform = tick()
692
				OnThrow(mouse.Hit.p,math.min(clickd/KnifeSettings.Charge_time,1))
693
				delay(KnifeSettings.Throw_speed/2,function()
694
					PlaySound("equip", 0.1)
695
				end)
696
				delay(KnifeSettings.Throw_speed,function()
697
					if mouse_holding then
698
						click_start = tick()
699
					else
700
						click_start = math.huge
701
					end
702
				end)
703
			end
704
		elseif KnifeSettings.CanThrow then --Throw only
705
			PlaySound("Throw")
706
			throw_perform = tick()
707
			OnThrow(mouse.Hit.p,math.min(clickd/KnifeSettings.Charge_time,1))
708
			delay(KnifeSettings.Throw_speed/2,function()
709
				PlaySound("equip", 0.1)
710
			end)
711
			delay(KnifeSettings.Throw_speed,function()
712
				throw_perform = tick()
713
			end)
714
		elseif KnifeSettings.CanSlash then --Slash only
715
		end
716
	end)
717
	
718
	local conn = rs.RenderStepped:connect(function()
719
		if not running then return end
720
		local delta = tick() - last_c
721
		last_c = tick()
722
		local clickd = tick() - click_start
723
		
724
		if anim_equip > 0 then
725
			anim_equip = math.max(0, anim_equip - (delta / KnifeSettings.Equip_time))
726
			Animate("Equip", 1 - anim_equip)
727
		elseif mouse_holding and clickd >= Settings.ThrowChargeDelay then
728
			Animate("Charge", clickd/KnifeSettings.Charge_time)
729
			idle_perform = 0
730
		elseif tick() - throw_perform <= KnifeSettings.Throw_speed then
731
			Animate("Throw", (tick() - throw_perform) / KnifeSettings.Throw_speed)
732
			idle_perform = 0
733
		elseif tick() - attack_perform <= Settings.Attack_speed then
734
			Animate("Attack" .. attack_type, (tick() - attack_perform) / Settings.Attack_speed)
735
			idle_perform = 0
736
		elseif tick() - idle_perform <= Settings.Idle_speed then
737
			Animate("Idle" .. idle_type, (tick() - idle_perform) / Settings.Idle_speed)
738
		else
739
			Animate("Default", 0)
740
		end
741
		
742
		if tick() - last_action >= idle_rand then
743
			idle_rand = math.random(12, 20)
744
			last_action = tick()
745
			idle_perform = tick()
746
			idle_type = math.random(1, 2)
747
		end
748
		
749
	end)
750
	tool.Deselected:connect(function() running = false conn:disconnect() end)
751
end)
752
tool.Deselected:connect(function()
753
	RemoveSounds()
754
	humanoid.WalkSpeed = walkspeeds[1]
755
end)
756
757
--Murderer knife animation module, original code from The Mad Murderer, by loleris.
758
759
local tool = script.Parent
760
local player = game.Players.LocalPlayer
761
local character = player.Character
762
local humanoid = character:findFirstChild("Humanoid")
763
local camera = Workspace.CurrentCamera
764
local mouse = player:GetMouse()
765
766
local conn_type = "Snap"
767
768
local anim_head = false
769
770
weapon_properties = {
771
	mesh_id = "http://www.roblox.com/asset/?id=121944778",
772
	texture_id = "http://www.roblox.com/asset/?id=121944805", --ADD TEXTURE HERE------------------------------------------------
773
	scale = Vector3.new(0.6, 0.6, 0.6),
774
	transparency = 0,
775
	reflectance = 0,
776
	brick_color = BrickColor.new("Really black"),
777
}
778
779
--How did I make all of this? Magic. Didn't even need an animation editor :)
780
Animations = {
781
	Default = {
782
		{{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)}
783
	},
784
	Equip = {
785
		{{}, 0, CFrame.new(0, 0, 0) * CFrame.Angles(-1.571, 0, 0), CFrame.new(0, 0, 0) * CFrame.Angles(-1.571, 0, 0), CFrame.new(0, -1.3, -0.5) * CFrame.Angles(-2.618, 0, 0)},
786
		{{0.8, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.524, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
787
		{{0.2, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
788
	},
789
	Idle1 = {
790
		{{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
791
		{{0.3, 2}, 0, CFrame.new(0.8, -0.301, 0.2) * CFrame.Angles(-0.35, 0, 0.872), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0.523, 1.221, -0.699), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 1.221, 0)},
792
		{{0.55, 2}, 0, CFrame.new(0.2, -0.5, 0.2) * CFrame.Angles(-0.14, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0, 1.221, -0.175), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.746, 1.221, 0.174)},
793
		{{0.15, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
794
	},
795
	Idle2 = {
796
		{{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
797
		{{0.3, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.524, 0, 0.872), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, -0.175, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0.523, 0)},
798
		{{0.3, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(0.349, 0, 0.523), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0.174, 0.698, -0.524), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, -1.222, 0)},
799
		{{0.2, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(0.61, 0, 0.349), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0.139, 0.663, -0.489), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, -1.222, 0)},
800
		{{0.2, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)}
801
	},
802
	Attack1 = {
803
		{{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
804
		{{0.25, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-1.048, 0, 0.349), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0.872, 0.349, 0.087), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
805
		{{0.15, 2}, 0, CFrame.new(0.4, -0.101, 0.1) * CFrame.Angles(-1.571, 0, -0.35), CFrame.new(-0.301, -0.301, 0.1) * CFrame.Angles(-1.048, -0.175, -0.524), CFrame.new(0, -1.201, -0.801) * CFrame.Angles(-2.095, 0, 0)},
806
		{{0.6, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)}
807
	},
808
	Attack2 = {
809
		{{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
810
		{{0.25, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.699, 0, 0.872), CFrame.new(-0.401, 0.3, 0.1) * CFrame.Angles(1.919, 2.443, -1.222), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
811
		{{0.15, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-1.048, 0, -0.524), CFrame.new(-0.5, -0.201, -0.101) * CFrame.Angles(0.523, 1.396, -0.873), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
812
		{{0.6, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)}
813
	},
814
	Attack3 = {
815
		{{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
816
		{{0.25, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-1.397, 0, 0.174), CFrame.new(-0.401, -0.201, 0) * CFrame.Angles(1.396, 0.698, -1.571), CFrame.new(0, -1.3, -0.401) * CFrame.Angles(-2.444, 0, 0)},
817
		{{0.15, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-1.397, 0, 0.174), CFrame.new(-0.401, 0.1, 0) * CFrame.Angles(0.349, 2.094, -0.524), CFrame.new(0, -1.3, 0.1) * CFrame.Angles(-3.84, 0, 0)},
818
		{{0.6, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)} --Psst. Create a dummy, try setting position and angles of limbs and the weapon, save CFrame data to code. Easy? Yes. When making a single knife tool, it was all you needed.
819
	},
820
	Charge = {
821
		{{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
822
		{{1, 2}, 0, CFrame.new(0.5, -0.301, 0.2) * CFrame.Angles(-0.35, 0, 1.047), CFrame.new(-0.201, 0, -0.201) * CFrame.Angles(1.396, 0.087, 0.174), CFrame.new(0, -0.801, -0.801) * CFrame.Angles(-1.222, 0, 0)}
823
	},
824
	Throw = {
825
		{{}, 1, CFrame.new(0.5, -0.301, 0.2) * CFrame.Angles(-0.35, 0, 1.047), CFrame.new(-0.201, 0, -0.201) * CFrame.Angles(1.396, 0.087, 0.174), CFrame.new(0, -0.801, -0.801) * CFrame.Angles(-1.222, 0, 0)},
826
		{{0.1, 2}, 1, CFrame.new(0.5, -0.301, 0.2) * CFrame.Angles(-0.873, 0, 0.523), CFrame.new(-0.201, -0.201, 0.1) * CFrame.Angles(-0.35, 0.087, -0.175), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
827
		{{0.5, 2}, 1, CFrame.new(0.5, -0.401, 0.2) * CFrame.Angles(-0.699, 0, 0.872), CFrame.new(-0.201, -0.201, 0) * CFrame.Angles(-1.92, -0.175, 0.174), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
828
		{{0, 2}, 0, CFrame.new(0.5, -0.401, 0.2) * CFrame.Angles(-0.699, 0, 0.872), CFrame.new(-0.201, -0.201, 0) * CFrame.Angles(-1.92, -0.175, 0.174), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
829
		{{0.4, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)}
830
	}
831
}
832
833
834
function CFrameTrans(GetCFrame1, GetCFrame2, GetNumber)
835
	local Diff2 = GetCFrame2.p - GetCFrame1.p
836
	local GetCFrame1_s = GetCFrame1 - GetCFrame1.p
837
	GetCFrame2 = GetCFrame2 - GetCFrame2.p
838
	local Diff = GetCFrame1_s:inverse() * GetCFrame2
839
	local x1, y1, z1 = Diff:toEulerAnglesXYZ()
840
	return (GetCFrame1 + (Diff2 * GetNumber)) * CFrame.Angles(x1 * GetNumber, y1 * GetNumber, z1 * GetNumber)
841
end
842
843
function TransEff(x, type)
844
	if type == 1 then
845
		return x
846
	elseif type == 2 then
847
		return x*x*(3 - 2*x)
848
	elseif type == 3 then
849
		return math.sin(math.rad(x * 90))
850
	elseif type == 4 then
851
		return 1 - math.sin(math.rad((1 - x) * 90))
852
	end
853
end
854
855
function num_trans(n1, n2, x)
856
	return n1 + ((n2 - n1) * x)
857
end
858
859
function PlayAnimation(animd, tm) --return {left, right, wep, trans}
860
	tm = math.min(1, math.max(0, tm))
861
	local anim = Animations[animd]
862
	if #anim == 1 then
863
		return {anim[1][3], anim[1][4], anim[1][5], anim[1][2]}
864
	else
865
		local trans_from = 1
866
		local trans_to = 1
867
		local tm_left = tm
868
		for i = 2, #anim do
869
			tm_left = tm_left - anim[i][1][1]
870
			if tm_left <= 0 then
871
				trans_from = i - 1
872
				trans_to = i
873
				break
874
			end
875
		end
876
		local trans_amm = TransEff((anim[trans_to][1][1] + tm_left) / anim[trans_to][1][1], anim[trans_to][1][2])
877
		return {
878
			CFrameTrans(anim[trans_from][3], anim[trans_to][3], trans_amm),
879
			CFrameTrans(anim[trans_from][4], anim[trans_to][4], trans_amm),
880
			CFrameTrans(anim[trans_from][5], anim[trans_to][5], trans_amm),
881
			num_trans(anim[trans_from][2], anim[trans_to][2], trans_amm)
882
		}
883
	end
884
end
885
886
rot_amplitude_head = 20
887
rot_amplitude_chest = 15
888
889
anim_p = {
890
	cam_offset = CFrame.new(0.2, -0.37, 0.91) * CFrame.Angles(math.rad(0), math.rad(0), math.rad(0)),
891
	aim_amp = 0.5,
892
	aim_max_change = 4,
893
	aim_retract = 15,
894
	aim_max_deg = 20,
895
}
896
897
local weapon_model = Instance.new("Part")
898
weapon_model.CanCollide = false
899
weapon_model.Name = "WeaponObject"
900
weapon_model.formFactor = "Custom"
901
weapon_model.Size = Vector3.new(0.2, 0.2, 0.2)
902
weapon_model.TopSurface = 0
903
weapon_model.BottomSurface = 0
904
weapon_model.BrickColor = weapon_properties.brick_color
905
weapon_model.Transparency = weapon_properties.transparency
906
weapon_model.Reflectance = weapon_properties.reflectance
907
local mesh = Instance.new("SpecialMesh", weapon_model)
908
mesh.Scale = weapon_properties.scale
909
mesh.MeshId = weapon_properties.mesh_id
910
mesh.TextureId = weapon_properties.texture_id
911
912
torso = character.Torso
913
head = character.Head
914
915
motors = {torso:findFirstChild("Left Shoulder"), torso:findFirstChild("Right Shoulder"), torso:findFirstChild("Neck")}
916
welds = {nil, nil, nil}
917
weapon_parts = {weapon_model:clone(), weapon_model:clone()}
918
weapon_model = nil
919
920
function EndAnimation()
921
	if motors[1] then
922
		motors[1].Part1 = character:findFirstChild("Left Arm")
923
	end
924
	if motors[2] then
925
		motors[2].Part1 = character:findFirstChild("Right Arm")
926
	end
927
	if motors[3] then
928
		motors[3].Part1 = character:findFirstChild("Head")
929
	end
930
	if welds[1] then
931
		welds[1]:remove()
932
		welds[1] = nil
933
	end
934
	if welds[2] then
935
		welds[2]:remove()
936
		welds[2] = nil
937
	end
938
	if welds[3] then
939
		welds[3]:remove()
940
		welds[3] = nil
941
	end
942
	weapon_parts[1].Parent = nil
943
	if weapon_model then
944
		weapon_model.Parent = nil
945
	end
946
	coroutine.resume(coroutine.create(function()
947
		local swm = weapon_model
948
		wait()
949
		swm.Parent = nil
950
		wait(0.1)
951
		swm.Parent =  nil
952
		wait(0.5)
953
		swm.Parent =  nil
954
	end))
955
end
956
957
local anim_model = Instance.new("Model")
958
anim_model.Name = "WeaponAnimation"
959
weapon_model = anim_model
960
	
961
local cam_larm = Instance.new("Part")
962
cam_larm.Parent = anim_model
963
cam_larm.BrickColor = BrickColor.new("Really black")
964
cam_larm.formFactor = "Custom"
965
cam_larm.Size = Vector3.new(0.2, 0.2, 0.2)
966
cam_larm.TopSurface = 0
967
cam_larm.BottomSurface = 0
968
cam_larm.Transparency = 0.4
969
cam_larm.CanCollide = false
970
local hmesh = Instance.new("BlockMesh", cam_larm)
971
hmesh.Scale = Vector3.new(5, 10, 5)
972
973
local cam_rarm = cam_larm:clone()
974
cam_rarm.Parent = anim_model
975
976
function StartAnimation()
977
	local check = {torso:findFirstChild("LeftWeld"), torso:findFirstChild("RightWeld"), torso:findFirstChild("HeadWeld")}
978
	if check[1] then check[1]:remove() end
979
	if check[2] then check[2]:remove() end
980
	if check[3] then check[3]:remove() end
981
	local check2 = {character:findFirstChild("WeaponObject"), camera:findFirstChild("WeaponAnimation")}
982
	if check2[1] then check2[1].Parent = nil end
983
	if check2[2] then check2[2].Parent = nil end
984
	if motors[1] then
985
		motors[1].Part1 = nil
986
	end
987
	if motors[2] then
988
		motors[2].Part1 = nil
989
	end
990
	if motors[3] then
991
		motors[3].Part1 = nil
992
	end
993
	welds = {Instance.new(conn_type), Instance.new(conn_type), Instance.new(conn_type)}
994
	welds[1].Part0 = torso
995
	welds[2].Part0 = torso
996
	welds[3].Part0 = torso
997
	welds[1].Part1 = character:findFirstChild("Left Arm")
998
	welds[2].Part1 = character:findFirstChild("Right Arm")
999
	welds[3].Part1 = character:findFirstChild("Head")
1000
	welds[1].Name = "LeftWeld"
1001
	welds[2].Name = "RightWeld"
1002
	welds[2].Name = "HeadWeld"
1003
	welds[1].C0 = CFrame.new(-1.5, 0, 0)
1004
	welds[2].C0 = CFrame.new(1.5, 0, 0)
1005
	welds[3].C0 = CFrame.new(0, 1.5, 0)
1006
	welds[1].Parent = torso
1007
	welds[2].Parent = torso
1008
	welds[3].Parent = torso
1009
	
1010
	weapon_parts[1].Parent = character
1011
	local wep_weld = Instance.new(conn_type)
1012
	wep_weld.Part0 = character:findFirstChild("Right Arm")
1013
	wep_weld.Part1 = weapon_parts[1]
1014
	wep_weld.C0 = CFrame.new()
1015
	wep_weld.Parent = weapon_parts[1]
1016
	
1017
	local weld1 = welds[1]
1018
	local weld2 = welds[2]
1019
	local weld3 = welds[3]
1020
	
1021
	local cam_welds = {Instance.new(conn_type), Instance.new(conn_type), Instance.new(conn_type)}
1022
	cam_welds[1].Part0 = torso
1023
	cam_welds[1].Part1 = cam_larm
1024
	cam_welds[1].Parent = cam_larm
1025
	cam_welds[2].Part0 = torso
1026
	cam_welds[2].Part1 = cam_rarm
1027
	cam_welds[2].Parent = cam_rarm
1028
	cam_welds[3].Part0 = cam_rarm
1029
	cam_welds[3].Part1 = weapon_parts[2]
1030
	cam_welds[3].Parent = weapon_parts[2]
1031
	weapon_parts[2].Parent = anim_model
1032
	
1033
	local move_anim_speed = 3
1034
	local last_p = Vector3.new()
1035
	local move_amm = 0
1036
	coroutine.resume(coroutine.create(function()
1037
		while weld1.Parent ~= nil do
1038
			local delta = wait(1/25)
1039
			local cur_p = torso.Position
1040
			if (cur_p - last_p).magnitude >= 0.1 then
1041
				move_amm = math.min(1, move_amm + delta * move_anim_speed)
1042
			else
1043
				move_amm = math.max(0, move_amm - delta * move_anim_speed)
1044
			end
1045
			last_p = cur_p
1046
		end
1047
	end))
1048
	
1049
	local r_serv = game:GetService("RunService")
1050
	
1051
	--EASTER EGG
1052
	function easein(x)
1053
		return math.sin(math.rad(x * 90))
1054
	end
1055
1056
	local a_horse = (character:findFirstChild("HorseHead") ~= nil)
1057
	local horse_displace = {0, 0}
1058
	local horse_cf = CFrame.Angles(0.0001, 0.0001, 0)
1059
	if a_horse then
1060
		coroutine.resume(coroutine.create(function()
1061
			while weld1.Parent ~= nil do
1062
				local rndwait = (math.random(100, 1000) / 1000) * 4
1063
				wait(rndwait)
1064
				local oldd = {horse_displace[1], horse_displace[2]}
1065
				local disp2 = {math.random(-60, 60), math.random(0, 25)}
1066
				
1067
				local ld = 0
1068
				while ld ~= 1 do
1069
					local st = tick()
1070
					r_serv.RenderStepped:wait()
1071
					ld = math.min(1, ld + ((tick() - st) * 4))
1072
					local eff = easein(ld)
1073
					
1074
					local x = oldd[1] - ((oldd[1] - disp2[1]) * eff)
1075
					local y = oldd[2] - ((oldd[2] - disp2[2]) * eff)
1076
					horse_displace = {x, y}
1077
					horse_cf = CFrame.Angles(math.rad(y), math.rad(x) , 0)
1078
				end
1079
			end
1080
		end))
1081
	end
1082
	
1083
	--EASTER EGG
1084
	
1085
	local last_va = 0
1086
	local last_va2 = 0
1087
	local view_velocity = {0, 0}
1088
	
1089
	coroutine.resume(coroutine.create(function()
1090
		local last_time = tick()
1091
		while weld1.Parent ~= nil do
1092
			r_serv.RenderStepped:wait() ------------------------------------------------
1093
			local delta = tick() - last_time
1094
			last_time = tick()
1095
			
1096
			local breathe_amp = 2
1097
			local breathe_freq = 0.8
1098
			local breathe = math.sin(math.rad(tick() * 90 * breathe_freq)) * breathe_amp
1099
			
1100
			local shake_freq = 5
1101
			local shake_amp = {0.05, 0.05}
1102
			local arm_shake = CFrame.new(
1103
				math.sin(math.rad(tick() * 90 * shake_freq)) * move_amm * shake_amp[1],
1104
				0,
1105
				math.abs(math.sin(math.rad(tick() * 90 * shake_freq)) * move_amm * shake_amp[2]))
1106
1107
1108
			--ANIMATION LOOP
1109
			local p_distance = (head.Position - mouse.Hit.p).magnitude
1110
			if p_distance == 0 then p_distance = 0.0001 end
1111
			local p_height = mouse.Hit.p.y - head.Position.y
1112
			local view_angle 
1113
			if p_height ~= 0 then
1114
				view_angle = math.deg(math.asin(math.abs(p_height) / p_distance)) * (math.abs(p_height) / p_height)
1115
			else
1116
				view_angle = 0
1117
			end
1118
			
1119
			local cam_cf = camera.CoordinateFrame
1120
			local looking_at = cam_cf * CFrame.new(0, 0, -100)
1121
			local view_angle2 = math.deg(math.atan2(cam_cf.p.x - looking_at.p.x, cam_cf.p.z - looking_at.p.z)) + 180
1122
			
1123
			local v_delta1, v_delta2
1124
			local dir1 = 0
1125
			local dir2 = 0
1126
			v_delta1 = math.abs(view_angle - last_va)
1127
			if v_delta1 ~= 0 then
1128
				dir1 = (view_angle - last_va) / v_delta1
1129
			end
1130
			local va_check = {math.abs(view_angle2 - last_va2), 360 - math.abs(view_angle2 - last_va2)}
1131
			if view_angle2 == last_va2 then
1132
				dir2 = 0
1133
				v_delta2 = 0
1134
			elseif va_check[1] < va_check[2] then
1135
				v_delta2 = va_check[1]
1136
				dir2 = (view_angle2 - last_va2) / va_check[1]
1137
			else
1138
				v_delta2 = va_check[2]
1139
				if last_va2 > view_angle2 then
1140
					dir2 = 1
1141
				else
1142
					dir2 = -1
1143
				end
1144
			end
1145
			last_va = view_angle
1146
			last_va2 = view_angle2
1147
			
1148
			view_velocity[1] = view_velocity[1] / (1 + (delta * anim_p.aim_retract))
1149
			view_velocity[2] = view_velocity[2] / (1 + (delta * anim_p.aim_retract))
1150
			
1151
			local calc1 = v_delta1 * dir1 * anim_p.aim_amp
1152
			if calc1 ~= 0 then
1153
				view_velocity[1] = view_velocity[1] + (math.min(anim_p.aim_max_change, math.abs(calc1)) * (calc1 / math.abs(calc1)))
1154
			end
1155
			local calc2 = v_delta2 * dir2 * anim_p.aim_amp
1156
			if calc2 ~= 0 then
1157
				view_velocity[2] = view_velocity[2] + (math.min(anim_p.aim_max_change, math.abs(calc2)) * (calc2 / math.abs(calc2)))
1158
			end
1159
			
1160
			if view_velocity[1] ~= 0 then
1161
				view_velocity[1] = math.min(anim_p.aim_max_deg, math.abs(view_velocity[1])) * (math.abs(view_velocity[1]) / view_velocity[1])
1162
			end
1163
			if view_velocity[2] ~= 0 then
1164
				view_velocity[2] = math.min(anim_p.aim_max_deg, math.abs(view_velocity[2])) * (math.abs(view_velocity[2]) / view_velocity[2])
1165
			end
1166
			
1167
			local anmtp = _G.MurderKnife_AnimType
1168
			local anmst = _G.MurderKnife_AnimState
1169
			
1170
			if anmst == nil then
1171
				anmst = 0
1172
			end
1173
			
1174
			if anmtp ~= nil then
1175
				if Animations[anmtp] == nil then
1176
					anmtp = "Default"
1177
				end
1178
			else
1179
				anmtp = "Default"
1180
			end
1181
			local curr_anim = PlayAnimation(anmtp, anmst) --left, right, weapon, wep trans
1182
			
1183
			--curr_anim = {Animations.Default[1][3], Animations.Default[1][4], Animations.Default[1][5], 0}
1184
			
1185
			local chestCF = CFrame.new(0, 0.5, 0) * CFrame.Angles(math.rad(math.max(-rot_amplitude_chest, math.min(rot_amplitude_chest, view_angle)) + 90 + breathe), 0, 0)
1186
			weld1.C1 = (chestCF * curr_anim[1] * CFrame.new(0, -0.5, 0)):inverse()
1187
			weld2.C1 = (chestCF * curr_anim[2] * CFrame.new(0, -0.5, 0)):inverse()
1188
			wep_weld.C1 = (curr_anim[3]):inverse()
1189
			weapon_parts[1].Transparency = curr_anim[4]
1190
			if anim_head then
1191
				weld3.C1 = (CFrame.new(0, 0, 0) * CFrame.Angles(math.rad(math.max(-rot_amplitude_head, math.min(rot_amplitude_head, view_angle))), 0, 0) * horse_cf):inverse()
1192
			else
1193
				weld3.C1 = (CFrame.new(0, 0, 0)):inverse()
1194
			end
1195
			
1196
			if (head.Position - camera.CoordinateFrame.p).magnitude < 3 then
1197
				if anim_model.Parent == nil then
1198
					anim_model.Parent = camera
1199
				end
1200
				cam_welds[1].Parent = cam_larm
1201
				cam_welds[2].Parent = cam_rarm
1202
				cam_welds[3].Parent = weapon_parts[2]
1203
				for _,c in pairs(cam_larm:GetChildren()) do
1204
					if c:IsA("Snap") and c ~= cam_welds[1] then
1205
						c:remove()
1206
					end
1207
				end
1208
				for _,c in pairs(cam_rarm:GetChildren()) do
1209
					if c:IsA("Snap") and c ~= cam_welds[2] then
1210
						c:remove()
1211
					end
1212
				end
1213
				for _,c in pairs(weapon_parts[2]:GetChildren()) do
1214
					if c:IsA("Snap") and c ~= cam_welds[3] then
1215
						c:remove()
1216
					end
1217
				end
1218
				local cam_cf = camera.CoordinateFrame * CFrame.Angles(math.rad(90 + (breathe / 2) - view_velocity[1]), 0, math.rad(view_velocity[2])) * arm_shake * anim_p.cam_offset
1219
				cam_welds[1].C1 = (torso.CFrame:inverse() * cam_cf * CFrame.new(-1.5, 0, 0) * curr_anim[1] * CFrame.new(0, -0.5, 0)):inverse()
1220
				cam_welds[2].C1 = (torso.CFrame:inverse() * cam_cf * CFrame.new(1.5, 0, 0) * curr_anim[2] * CFrame.new(0, -0.5, 0)):inverse()
1221
				cam_welds[3].C1 = (curr_anim[3]):inverse()
1222
				weapon_parts[2].Transparency = curr_anim[4]
1223
			else
1224
				if anim_model.Parent ~= nil then
1225
					anim_model.Parent = nil
1226
				end
1227
			end
1228
			--ANIMATION LOOP
1229
		end
1230
	end))
1231
end
1232
1233
local last_st = 0
1234
local eq = false
1235
tool.Selected:connect(function(mouse)
1236
	if eq then return end
1237
	eq = true
1238
	wait()
1239
	StartAnimation()
1240
end)
1241
1242
tool.Deselected:connect(function()
1243
	eq = false
1244
	EndAnimation()
1245
end)