--Scripted by Tsuneoo, I hope you enjoy it! :D
--Don't remove the "ReloadKnife" script, or the knife won't be working good!


wait()
local CMouse = require(script.CMouse)
while not CMouse:GetPlayer() do
	 game:GetService("RunService").Hearbeat:Wait()
end

local SpeedBoost = 20 --Gives you more WalkSpeed when Equipped. You can change the 3 to any number you want.

local tool = script.Parent

local handle = script.Parent:WaitForChild("Handle")

local killsound = handle:WaitForChild("Kill")

local outsound = handle:WaitForChild("Out")

local sticksound = handle:WaitForChild("Stick")

local swooshsound = handle:WaitForChild("Swoosh")

local throwsound = handle:WaitForChild("Throw")

local player = CMouse:GetPlayer()
while player.Character == nil do wait() end
local char = player.Character
local p_mouse = CMouse

local speedAdj = {

	function(i)
		return math.sin((i*math.pi)-(math.pi/2))/2 + 0.5
	end,

	function(i)
		return math.sin(((i-1)*(math.pi/2)))+1
	end,

	function(i)
		return math.sin(i*(math.pi/2))
	end,
	function(i) return i end
}

aWd = {}

weldBase = {}
weldAtc = {}

local shiftStart = {}

function updateArms()
	aWd[1].C0 = weldBase[aWd[1]]*weldAtc[aWd[1]]
	aWd[2].C0 = weldBase[aWd[2]]*weldAtc[aWd[2]]
end

function shiftWeld(weld,targ,spd,tm)
	local runServ = game:GetService("RunService")

	local c1 = {weldAtc[weld]:components()}
	local c2 = {targ:components()}
	local c3 = {}

	local adjF = nil
	if spd == nil or speedAdj[spd] == nil then
		adjF = speedAdj[4]
	else
		adjF = speedAdj[spd]
	end

	local exe = tick()
	shiftStart[weld] = exe
	spawn(function()
		while tick()<exe+tm and shiftStart[weld] == exe do
			local amt = adjF((tick()-exe)/tm)
			for i = 1,12 do
				c3[i] = (c1[i]*(1-amt))+(c2[i]*amt)
			end
			weldAtc[weld] = CFrame.new(unpack(c3))
			runServ.Heartbeat:wait()
		end
		if shiftStart[weld] == exe then
			weldAtc[weld] = targ
		end
	end)
end

function weldArms()

	weldAtc[1] = char.Head.CFrame:inverse()*char["Right Arm"].CFrame
	weldAtc[2] = char.Head.CFrame:inverse()*char["Left Arm"].CFrame	

	local w = Instance.new("Weld")
	weldAtc[w] = char.Head.CFrame:inverse()*char["Right Arm"].CFrame
	weldBase[w] = CFrame.new()
	char.Torso["Right Shoulder"].Part1 = nil
	w.Part0 = char.Head
	w.Part1 = char["Right Arm"]
	w.Parent = char.Torso
	aWd[1] = w
	w = Instance.new("Weld")
	weldAtc[w] = char.Head.CFrame:inverse()*char["Left Arm"].CFrame
	weldBase[w] = CFrame.new()
	char.Torso["Left Shoulder"].Part1 = nil
	w.Part0 = char.Head
	w.Part1 = char["Left Arm"]
	w.Parent = char.Torso
	aWd[2] = w

	local f1 = char["Right Arm"]:Clone()
	f1:ClearAllChildren()
	f1.BrickColor = BrickColor.new("Black")
	f1.Transparency = 0.5
	Instance.new("BlockMesh").Parent = f1
	f1.Mesh.Scale = Vector3.new(0.99,0.99,0.99)
	Instance.new("Weld").Parent = f1
	f1.Weld.Part0 = char["Right Arm"]
	f1.Weld.Part1 = f1
	f1.Name = "FakeArm"
	local f2 = f1:Clone()
	f2.Weld.Part0 = char["Left Arm"]
	f2.Weld.Part1 = f2
	f1.Parent = workspace.CurrentCamera
	f2.Parent = workspace.CurrentCamera
	wait()
end

function fixArms()
	aWd[1]:Remove()
	aWd[2]:Remove()
	aWd[1] = nil
	aWd[2] = nil
	char.Torso["Left Shoulder"].Part1 = char["Left Arm"]
	char.Torso["Right Shoulder"].Part1 = char["Right Arm"]
end

eqTm = 0

function evalKill(hit)
	if slashing then
		if hit.Parent ~= nil and hit.Parent:FindFirstChild("Humanoid") ~= nil and hit.Parent.Humanoid.Health > 0 and not hit:IsDescendantOf(script.Parent.Parent) then
			if hit.Parent:FindFirstChild("Head") ~= nil then
				for _,s in ipairs(hit.Parent.Head:GetChildren()) do
					if s.className == "Sound" then
						s:Remove()
					end
				end
				handle.Kill:Clone().Parent = hit.Parent.Head
				hit.Parent.Head.Kill:Play()
				game.Debris:AddItem(hit.Parent.Head.Kill, 2)
			end
			hit.Parent.Humanoid:TakeDamage(100)
		end	
	end
end

handle.Touched:connect(evalKill)
handle.TouchEnded:connect(evalKill)

tool.Equipped:connect(function(mouse)
	mouse = CMouse
	char.Humanoid.WalkSpeed = char.Humanoid.WalkSpeed + SpeedBoost

	local exe = tick()
	eqTm = exe
	weldArms()
	updateArms()
	shiftWeld(aWd[1],CFrame.new(1.09999847, -1.15000033, -0.400005341, 0.992094874, 0.123806097, 0.0204437803, -0.0335917398, 0.419010431, -0.907359898, -0.120902866, 0.899500489, 0.419857204),1,0.4)
	shiftWeld(aWd[2],CFrame.new(-1.04000473, -1.4000001, -0.490007401, 0.933408856, -0.2452925, -0.261869907, 0.0565752126, 0.82131362, -0.567664564, 0.354320973, 0.51504761, 0.780499399),1,0.4)
	outsound:Play()

	local mdTm = 0	
	local canThrow = true
	local throwing = false
	mouse.Button1Down:connect(function()
		if tool.Parent == char then
			if canThrow then
				canThrow = false
				throwing = true
				mdTm = tick()
				shiftWeld(aWd[1],CFrame.new(1.09999847, -0.440001011, -0.400005341, 0.992094994, 0.0142743737, -0.124667041, -0.0335872695, -0.92704916, -0.373433173, -0.120903023, 0.374668688, -0.919241786),4,2)
			end
		end
	end)

	mouse.Button1Up:connect(function()
		if tool.Parent == char then
			if throwing then
				throwing = false
				if tick()-mdTm < 0.3 then
					slashing = true
					if math.random(0,1) == 1 then
						shiftWeld(aWd[1],CFrame.new(1.46999359, -1.15000105, -0.370010376, 0.138720512, -0.580347955, 0.802465916, 0.949465632, 0.308310717, 0.0588407367, -0.281556904, 0.753751874, 0.593789041),1,0.3)
						wait(0.3)
						shiftWeld(aWd[1],CFrame.new(0.760002136, -1.05000091, -0.590011597, 0.485976994, 0.191964433, 0.852628171, 0.8737849, -0.126958504, -0.469451755, 0.0181299299, 0.973156273, -0.229435116),1,0.2)
						swooshsound:Play()
						wait(0.2)
						shiftWeld(aWd[1],CFrame.new(1.09999847, -1.15000033, -0.400005341, 0.992094874, 0.123806097, 0.0204437803, -0.0335917398, 0.419010431, -0.907359898, -0.120902866, 0.899500489, 0.419857204),1,0.4)
						wait(0.2)
					else
						shiftWeld(aWd[1],CFrame.new(0.390003204, -0.950000763, -0.470010757, 0.415637791, 0.736434817, 0.5337677, 0.852281868, -0.110433385, -0.511296451, -0.317590654, 0.667434156, -0.673550844),1,0.3)
						wait(0.3)
						shiftWeld(aWd[1],CFrame.new(0.969997406, -1.51000047, -0.470010757, 0.837237597, -0.309994906, 0.450482845, 0.540366888, 0.595374048, -0.594590068, -0.0838864371, 0.741239488, 0.665979683),1,0.2)
						swooshsound:Play()					
						wait(0.2)
						shiftWeld(aWd[1],CFrame.new(1.09999847, -1.15000033, -0.400005341, 0.992094874, 0.123806097, 0.0204437803, -0.0335917398, 0.419010431, -0.907359898, -0.120902866, 0.899500489, 0.419857204),1,0.4)
						wait(0.2)
					end
					slashing = false
				else
					shiftWeld(aWd[1],CFrame.new(1.09999847, -1.15000033, -0.400005341, 0.992094874, 0.123806097, 0.0204437803, -0.0335917398, 0.419010431, -0.907359898, -0.120902866, 0.899500489, 0.419857204),1,0.2)
					if tick()-mdTm > 0.6 then
						local charge = (tick()-mdTm-0.5)/1.5
						if charge>1 then charge = 1 end
						wait(0.1)
						local thrown = handle:Clone()
						handle.Transparency = 1
						Instance.new("BodyForce").Parent = thrown
						thrown.BodyForce.force = Vector3.new(0,192.6*thrown:GetMass()*math.sqrt(charge),0)
						thrown.Name = player.Name
						thrown.Parent = workspace
						thrown.Velocity = (mouse.Hit.p-thrown.Position).unit*(73+(charge*73))
						thrown.CFrame = CFrame.new(thrown.Position,mouse.Hit.p)
						thrown.RotVelocity = Vector3.new(-thrown.CFrame.lookVector.Z,0,thrown.CFrame.lookVector.X)*-50
						thrown.Throw:Play()
						script.KnifeScript:Clone().Parent = thrown
						thrown.KnifeScript.Disabled = false
						wait(1)
						outsound:Play()
						handle.Transparency = 0
					end
				end
				wait(0.1)
				canThrow = true
			end
		end
	end)

		

	while eqTm == exe do
		updateArms()
		wait()
	end
end)

tool.Unequipped:connect(function()
	char.Humanoid.WalkSpeed = char.Humanoid.WalkSpeed - SpeedBoost
	eqTm = 0
	fixArms()
	while workspace.CurrentCamera:FindFirstChild("FakeArm") ~= nil do
		workspace.CurrentCamera.FakeArm:Remove()
	end
end)
